1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Implement thread_ctrl::wait_on (see #9208)

This commit is contained in:
Eladash 2021-01-21 17:03:09 +02:00 committed by Ivan
parent f81674232e
commit 12e1be2626
2 changed files with 18 additions and 1 deletions

View File

@ -234,6 +234,23 @@ public:
_wait_for(-1, true); _wait_for(-1, true);
} }
// Wait for both thread sync var and provided atomic var
template <typename T, atomic_wait::op op = atomic_wait::op::eq, typename U>
static inline void wait_on(T& wait, U old, u64 usec = -1)
{
auto _this = g_tls_this_thread;
if (_this->m_sync.bit_test_reset(2))
{
return;
}
atomic_wait::list<2> list{};
list.set<0, op>(wait, old);
list.set<1>(_this->m_sync, 0, 4 + 1);
list.wait(atomic_wait_timeout{usec <= 0xffff'ffff'ffff'ffff / 1000 ? usec * 1000 : 0xffff'ffff'ffff'ffff});
}
// Exit. // Exit.
[[noreturn]] static void emergency_exit(std::string_view reason); [[noreturn]] static void emergency_exit(std::string_view reason);

View File

@ -99,7 +99,7 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode)
if (old_status == ppu_join_status::joinable) if (old_status == ppu_join_status::joinable)
{ {
// Wait for termination // Wait for termination
ppu.joiner.wait(ppu_join_status::zombie); thread_ctrl::wait_on(ppu.joiner, ppu_join_status::zombie);
} }
ppu_thread_exit(ppu); ppu_thread_exit(ppu);