diff options
author | bunnei <bunneidev@gmail.com> | 2022-12-12 23:37:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-12 23:37:42 +0100 |
commit | 339a37f8cb19dffbf64015b5d9a362a1ef5560c2 (patch) | |
tree | 0742ac869b92b4ee7b2c49ef77547cdaeac5038d /src/core/cpu_manager.cpp | |
parent | Merge pull request #9406 from vonchenplus/topology (diff) | |
parent | general: improve handling of system startup failure (diff) | |
download | yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar.gz yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar.bz2 yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar.lz yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar.xz yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar.zst yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/cpu_manager.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 0dd4c2196..04a11f444 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -20,23 +20,20 @@ namespace Core { CpuManager::CpuManager(System& system_) : system{system_} {} CpuManager::~CpuManager() = default; -void CpuManager::ThreadStart(std::stop_token stop_token, CpuManager& cpu_manager, - std::size_t core) { - cpu_manager.RunThread(core); -} - void CpuManager::Initialize() { num_cores = is_multicore ? Core::Hardware::NUM_CPU_CORES : 1; gpu_barrier = std::make_unique<Common::Barrier>(num_cores + 1); for (std::size_t core = 0; core < num_cores; core++) { - core_data[core].host_thread = std::jthread(ThreadStart, std::ref(*this), core); + core_data[core].host_thread = + std::jthread([this, core](std::stop_token token) { RunThread(token, core); }); } } void CpuManager::Shutdown() { for (std::size_t core = 0; core < num_cores; core++) { if (core_data[core].host_thread.joinable()) { + core_data[core].host_thread.request_stop(); core_data[core].host_thread.join(); } } @@ -184,7 +181,7 @@ void CpuManager::ShutdownThread() { UNREACHABLE(); } -void CpuManager::RunThread(std::size_t core) { +void CpuManager::RunThread(std::stop_token token, std::size_t core) { /// Initialization system.RegisterCoreThread(core); std::string name; @@ -206,7 +203,9 @@ void CpuManager::RunThread(std::size_t core) { }); // Running - gpu_barrier->Sync(); + if (!gpu_barrier->Sync(token)) { + return; + } if (!is_async_gpu && !is_multicore) { system.GPU().ObtainContext(); |