From 7f28489c70cd457db27c8712baacfc85dea54b75 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 21 Jan 2021 19:04:18 +0200 Subject: [PATCH] Improve ppu_thread_cleaner a bit Always join thread. --- rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp index b19603e8ce..bd5770640c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_ppu_thread.cpp @@ -28,7 +28,15 @@ struct ppu_thread_cleaner { if (u32 id = old_id.exchange(new_id)) [[likely]] { - if (!idm::remove>(id)) [[unlikely]] + auto ppu = idm::get>(id); + + if (ppu) + { + // Join thread + (*ppu)(); + } + + if (!ppu || !idm::remove_verify>(id, std::move(ppu))) [[unlikely]] { sys_ppu_thread.fatal("Failed to remove detached thread 0x%x", id); }