summaryrefslogtreecommitdiff
path: root/src/core/cpu_manager.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2022-12-12 14:37:42 -0800
committerGravatar GitHub2022-12-12 14:37:42 -0800
commit339a37f8cb19dffbf64015b5d9a362a1ef5560c2 (patch)
tree0742ac869b92b4ee7b2c49ef77547cdaeac5038d /src/core/cpu_manager.cpp
parentMerge pull request #9406 from vonchenplus/topology (diff)
parentgeneral: improve handling of system startup failure (diff)
downloadyuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar.gz
yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.tar.xz
yuzu-339a37f8cb19dffbf64015b5d9a362a1ef5560c2.zip
Merge pull request #9398 from liamwhite/fail
general: improve handling of system startup failure
Diffstat (limited to 'src/core/cpu_manager.cpp')
-rw-r--r--src/core/cpu_manager.cpp15
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 {
20CpuManager::CpuManager(System& system_) : system{system_} {} 20CpuManager::CpuManager(System& system_) : system{system_} {}
21CpuManager::~CpuManager() = default; 21CpuManager::~CpuManager() = default;
22 22
23void CpuManager::ThreadStart(std::stop_token stop_token, CpuManager& cpu_manager,
24 std::size_t core) {
25 cpu_manager.RunThread(core);
26}
27
28void CpuManager::Initialize() { 23void CpuManager::Initialize() {
29 num_cores = is_multicore ? Core::Hardware::NUM_CPU_CORES : 1; 24 num_cores = is_multicore ? Core::Hardware::NUM_CPU_CORES : 1;
30 gpu_barrier = std::make_unique<Common::Barrier>(num_cores + 1); 25 gpu_barrier = std::make_unique<Common::Barrier>(num_cores + 1);
31 26
32 for (std::size_t core = 0; core < num_cores; core++) { 27 for (std::size_t core = 0; core < num_cores; core++) {
33 core_data[core].host_thread = std::jthread(ThreadStart, std::ref(*this), core); 28 core_data[core].host_thread =
29 std::jthread([this, core](std::stop_token token) { RunThread(token, core); });
34 } 30 }
35} 31}
36 32
37void CpuManager::Shutdown() { 33void CpuManager::Shutdown() {
38 for (std::size_t core = 0; core < num_cores; core++) { 34 for (std::size_t core = 0; core < num_cores; core++) {
39 if (core_data[core].host_thread.joinable()) { 35 if (core_data[core].host_thread.joinable()) {
36 core_data[core].host_thread.request_stop();
40 core_data[core].host_thread.join(); 37 core_data[core].host_thread.join();
41 } 38 }
42 } 39 }
@@ -184,7 +181,7 @@ void CpuManager::ShutdownThread() {
184 UNREACHABLE(); 181 UNREACHABLE();
185} 182}
186 183
187void CpuManager::RunThread(std::size_t core) { 184void CpuManager::RunThread(std::stop_token token, std::size_t core) {
188 /// Initialization 185 /// Initialization
189 system.RegisterCoreThread(core); 186 system.RegisterCoreThread(core);
190 std::string name; 187 std::string name;
@@ -206,7 +203,9 @@ void CpuManager::RunThread(std::size_t core) {
206 }); 203 });
207 204
208 // Running 205 // Running
209 gpu_barrier->Sync(); 206 if (!gpu_barrier->Sync(token)) {
207 return;
208 }
210 209
211 if (!is_async_gpu && !is_multicore) { 210 if (!is_async_gpu && !is_multicore) {
212 system.GPU().ObtainContext(); 211 system.GPU().ObtainContext();