[*] This was bothering me - 4b0a7c65 cont

This commit is contained in:
Reece Wilson 2023-09-12 21:56:58 +01:00
parent d661363247
commit 6ff27c6855
2 changed files with 8 additions and 11 deletions

View File

@ -27,7 +27,7 @@ namespace Aurora::Threading::Primitives
bool EventImpl::LockMS(AuUInt64 uTimeout /*=0*/) bool EventImpl::LockMS(AuUInt64 uTimeout /*=0*/)
{ {
return LockNS(AuMSToNS<AuUInt64>(uTimeout)); return this->LockNS(AuMSToNS<AuUInt64>(uTimeout));
} }
bool EventImpl::LockNS(AuUInt64 uTimeout /*=0*/) bool EventImpl::LockNS(AuUInt64 uTimeout /*=0*/)
@ -35,7 +35,7 @@ namespace Aurora::Threading::Primitives
AuInt64 uStartTime {}; AuInt64 uStartTime {};
AuInt64 uEndTime {}; AuInt64 uEndTime {};
if (AtomicIsEventSetLogicNoSpinNoLock()) if (this->AtomicIsEventSetLogicNoSpinNoLock())
{ {
return true; return true;
} }
@ -48,9 +48,9 @@ namespace Aurora::Threading::Primitives
if (gPreferFutexEvent) if (gPreferFutexEvent)
{ {
auto pSleepCounter = GetSleepCounter(); auto pSleepCounter = this->GetSleepCounter();
while (!AtomicIsEventSetLogicNoSpinNoLock()) while (!this->AtomicIsEventSetLogicNoSpinNoLock())
{ {
bool bStatus {}; bool bStatus {};
EventBits bits; EventBits bits;
@ -102,16 +102,16 @@ namespace Aurora::Threading::Primitives
bool EventImpl::LockAbsNS(AuUInt64 uEndTime) bool EventImpl::LockAbsNS(AuUInt64 uEndTime)
{ {
if (AtomicIsEventSetLogicNoSpinNoLock()) if (this->AtomicIsEventSetLogicNoSpinNoLock())
{ {
return true; return true;
} }
if (gPreferFutexEvent) if (gPreferFutexEvent)
{ {
auto pSleepCounter = GetSleepCounter(); auto pSleepCounter = this->GetSleepCounter();
while (!AtomicIsEventSetLogicNoSpinNoLock()) while (!this->AtomicIsEventSetLogicNoSpinNoLock())
{ {
bool bStatus {}; bool bStatus {};
EventBits bits; EventBits bits;

View File

@ -101,10 +101,7 @@ namespace Aurora::Threading::Primitives
AuAtomicAdd<AuUInt32>(&this->dwSleeping_, 1u); AuAtomicAdd<AuUInt32>(&this->dwSleeping_, 1u);
auto old = this->dwState_; while (!this->TryLockNoSpin())
//!tryLock (with old in a scope we can access)
while (!((old != 0) &&
(AuAtomicCompareExchange(&this->dwState_, old - 1, old) == old)))
{ {
if (uTimeout != 0) if (uTimeout != 0)
{ {