diff options
| author | 2018-05-03 00:16:12 -0400 | |
|---|---|---|
| committer | 2018-05-10 19:34:47 -0400 | |
| commit | cba69fdcd439c5f225bbddf1dad70e6326edd0dc (patch) | |
| tree | b608addf14d16c634cbe99a04e7931adfb2dbf31 /src/core/core_cpu.h | |
| parent | core: Implement multicore support. (diff) | |
| download | yuzu-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.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 @@ | |||
| 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 | ||
| 23 | class CpuBarrier { | 24 | class CpuBarrier { |
| 24 | public: | 25 | public: |
| 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 | ||
| 38 | private: | 34 | private: |
| 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 | ||
| 44 | class Cpu { | 41 | class Cpu { |