summaryrefslogtreecommitdiffstats
path: root/src/core/core_cpu.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-05-03 06:16:12 +0200
committerbunnei <bunneidev@gmail.com>2018-05-11 01:34:47 +0200
commitcba69fdcd439c5f225bbddf1dad70e6326edd0dc (patch)
treeb608addf14d16c634cbe99a04e7931adfb2dbf31 /src/core/core_cpu.h
parentcore: Implement multicore support. (diff)
downloadyuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar.gz
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar.bz2
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar.lz
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar.xz
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar.zst
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.zip
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 {