[*] Fix bugs in Mutex.NT.cpp

This commit is contained in:
Reece Wilson 2022-02-18 11:52:52 +00:00
parent df1c36bd28
commit fac6571504

View File

@ -62,14 +62,16 @@ namespace Aurora::Threading::Primitives
if (timeout != 0)
{
timeoutMs = endTime - static_cast<AuInt64>(Time::CurrentClockMS());
if (timeoutMs < 0)
startTime = Time::CurrentClockMS();
if (startTime >= endTime)
{
goto exitWin32;
}
timeoutMs = endTime - startTime;
}
status = SleepConditionVariableSRW(&wakeup_, &atomicHolder_, endTime, CONDITION_VARIABLE_LOCKMODE_SHARED);
status = SleepConditionVariableSRW(&wakeup_, &atomicHolder_, timeoutMs, CONDITION_VARIABLE_LOCKMODE_SHARED);
if (!status)
{
SysAssertExp(GetLastError() == ERROR_TIMEOUT);
@ -77,9 +79,9 @@ namespace Aurora::Threading::Primitives
}
}
exitWin32:
returnValue = true;
exitWin32:
ReleaseSRWLockShared(&atomicHolder_);
return returnValue;
}