Improve ppu_thread_cleaner a bit

Always join thread.
This commit is contained in:
Eladash 2021-01-21 19:04:18 +02:00 committed by Ivan
parent a58c12db0b
commit 7f28489c70
1 changed files with 9 additions and 1 deletions

View File

@ -28,7 +28,15 @@ struct ppu_thread_cleaner
{ {
if (u32 id = old_id.exchange(new_id)) [[likely]] if (u32 id = old_id.exchange(new_id)) [[likely]]
{ {
if (!idm::remove<named_thread<ppu_thread>>(id)) [[unlikely]] auto ppu = idm::get<named_thread<ppu_thread>>(id);
if (ppu)
{
// Join thread
(*ppu)();
}
if (!ppu || !idm::remove_verify<named_thread<ppu_thread>>(id, std::move(ppu))) [[unlikely]]
{ {
sys_ppu_thread.fatal("Failed to remove detached thread 0x%x", id); sys_ppu_thread.fatal("Failed to remove detached thread 0x%x", id);
} }