summaryrefslogtreecommitdiff
path: root/src/core/core_cpu.h
diff options
context:
space:
mode:
authorGravatar bunnei2018-05-03 00:16:12 -0400
committerGravatar bunnei2018-05-10 19:34:47 -0400
commitcba69fdcd439c5f225bbddf1dad70e6326edd0dc (patch)
treeb608addf14d16c634cbe99a04e7931adfb2dbf31 /src/core/core_cpu.h
parentcore: Implement multicore support. (diff)
downloadyuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar.gz
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.tar.xz
yuzu-cba69fdcd439c5f225bbddf1dad70e6326edd0dc.zip
core: Support session close with multicore.
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 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <atomic>
7#include <condition_variable> 8#include <condition_variable>
8#include <memory> 9#include <memory>
9#include <mutex> 10#include <mutex>
@@ -22,23 +23,19 @@ constexpr unsigned NUM_CPU_CORES{4};
22 23
23class CpuBarrier { 24class CpuBarrier {
24public: 25public:
25 void Rendezvous() { 26 bool IsAlive() const {
26 std::unique_lock<std::mutex> lock(mutex); 27 return !end;
28 }
27 29
28 --cores_waiting; 30 void NotifyEnd();
29 if (!cores_waiting) {
30 cores_waiting = NUM_CPU_CORES;
31 condition.notify_all();
32 return;
33 }
34 31
35 condition.wait(lock); 32 bool Rendezvous();
36 }
37 33
38private: 34private:
39 unsigned cores_waiting{NUM_CPU_CORES}; 35 unsigned cores_waiting{NUM_CPU_CORES};
40 std::mutex mutex; 36 std::mutex mutex;
41 std::condition_variable condition; 37 std::condition_variable condition;
38 std::atomic<bool> end{};
42}; 39};
43 40
44class Cpu { 41class Cpu {