summaryrefslogtreecommitdiffstats
path: root/src/core/core_cpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/core_cpu.h')
-rw-r--r--src/core/core_cpu.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h
index 06784c4ab..243f0b5e7 100644
--- a/src/core/core_cpu.h
+++ b/src/core/core_cpu.h
@@ -4,6 +4,7 @@
#pragma once
+#include <atomic>
#include <condition_variable>
#include <memory>
#include <mutex>
@@ -22,23 +23,19 @@ constexpr unsigned NUM_CPU_CORES{4};
class CpuBarrier {
public:
- void Rendezvous() {
- std::unique_lock<std::mutex> lock(mutex);
+ bool IsAlive() const {
+ return !end;
+ }
- --cores_waiting;
- if (!cores_waiting) {
- cores_waiting = NUM_CPU_CORES;
- condition.notify_all();
- return;
- }
+ void NotifyEnd();
- condition.wait(lock);
- }
+ bool Rendezvous();
private:
unsigned cores_waiting{NUM_CPU_CORES};
std::mutex mutex;
std::condition_variable condition;
+ std::atomic<bool> end{};
};
class Cpu {