mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Fix #2300
This commit is contained in:
parent
b21fce4d6f
commit
aef5113d49
@ -2055,21 +2055,9 @@ bool thread_ctrl::_wait_for(u64 usec)
|
||||
}
|
||||
_lock{_this->m_mutex};
|
||||
|
||||
if (u32 sig = _this->m_signal.load())
|
||||
{
|
||||
thread_ctrl::test();
|
||||
|
||||
if (sig & 1)
|
||||
{
|
||||
_this->m_signal &= ~1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_this->m_mutex.wait();
|
||||
|
||||
while (_this->m_cond.wait(_lock, usec))
|
||||
do
|
||||
{
|
||||
// Mutex is unlocked at the start and after the waiting
|
||||
if (u32 sig = _this->m_signal.load())
|
||||
{
|
||||
thread_ctrl::test();
|
||||
@ -2081,13 +2069,16 @@ bool thread_ctrl::_wait_for(u64 usec)
|
||||
}
|
||||
}
|
||||
|
||||
if (usec != -1)
|
||||
if (usec == 0)
|
||||
{
|
||||
// No timeout: return immediately
|
||||
return false;
|
||||
}
|
||||
|
||||
// Lock (semaphore)
|
||||
_this->m_mutex.wait();
|
||||
|
||||
// Double-check the value
|
||||
if (u32 sig = _this->m_signal.load())
|
||||
{
|
||||
if (sig & 2 && _this->m_exception)
|
||||
@ -2103,6 +2094,7 @@ bool thread_ctrl::_wait_for(u64 usec)
|
||||
}
|
||||
}
|
||||
}
|
||||
while (_this->m_cond.wait(_lock, std::exchange(usec, usec == -1 ? -1 : 0)));
|
||||
|
||||
// Timeout
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user