fix race condition in cResetEvent::Wait(u32)

This commit is contained in:
Flyinghead 2020-05-01 13:06:07 +02:00
parent d75d4400f0
commit e8a655d99b
1 changed files with 4 additions and 6 deletions

View File

@ -195,14 +195,12 @@ void cResetEvent::Reset()
bool cResetEvent::Wait(u32 msec)
{
bool rc = true;
std::unique_lock<std::mutex> lock(mutx);
std::unique_lock<std::mutex> lock(mutx);
if (!state) {
rc = (cond.wait_for(lock, std::chrono::milliseconds(msec)) == std::cv_status::no_timeout);
}
if (!state)
cond.wait_for(lock, std::chrono::milliseconds(msec));
bool rc = state;
state = false;
return rc;