diff options
author | bunnei <bunneidev@gmail.com> | 2018-05-03 06:16:12 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-05-11 01:34:47 +0200 |
commit | cba69fdcd439c5f225bbddf1dad70e6326edd0dc (patch) | |
tree | b608addf14d16c634cbe99a04e7931adfb2dbf31 /src/core/core_cpu.h | |
parent | core: Implement multicore support. (diff) | |
download | yuzu-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.h | 17 |
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 { |