From 6ff27c685532e5082a01ff7069fbb536c16eec8a Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 12 Sep 2023 21:56:58 +0100 Subject: [PATCH] [*] This was bothering me - 4b0a7c65 cont --- Source/Threading/Primitives/AuEvent.cpp | 14 +++++++------- Source/Threading/Primitives/AuSemaphore.Linux.cpp | 5 +---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Source/Threading/Primitives/AuEvent.cpp b/Source/Threading/Primitives/AuEvent.cpp index b4c173a1..03fb1477 100644 --- a/Source/Threading/Primitives/AuEvent.cpp +++ b/Source/Threading/Primitives/AuEvent.cpp @@ -27,7 +27,7 @@ namespace Aurora::Threading::Primitives bool EventImpl::LockMS(AuUInt64 uTimeout /*=0*/) { - return LockNS(AuMSToNS(uTimeout)); + return this->LockNS(AuMSToNS(uTimeout)); } bool EventImpl::LockNS(AuUInt64 uTimeout /*=0*/) @@ -35,7 +35,7 @@ namespace Aurora::Threading::Primitives AuInt64 uStartTime {}; AuInt64 uEndTime {}; - if (AtomicIsEventSetLogicNoSpinNoLock()) + if (this->AtomicIsEventSetLogicNoSpinNoLock()) { return true; } @@ -48,9 +48,9 @@ namespace Aurora::Threading::Primitives if (gPreferFutexEvent) { - auto pSleepCounter = GetSleepCounter(); + auto pSleepCounter = this->GetSleepCounter(); - while (!AtomicIsEventSetLogicNoSpinNoLock()) + while (!this->AtomicIsEventSetLogicNoSpinNoLock()) { bool bStatus {}; EventBits bits; @@ -102,16 +102,16 @@ namespace Aurora::Threading::Primitives bool EventImpl::LockAbsNS(AuUInt64 uEndTime) { - if (AtomicIsEventSetLogicNoSpinNoLock()) + if (this->AtomicIsEventSetLogicNoSpinNoLock()) { return true; } if (gPreferFutexEvent) { - auto pSleepCounter = GetSleepCounter(); + auto pSleepCounter = this->GetSleepCounter(); - while (!AtomicIsEventSetLogicNoSpinNoLock()) + while (!this->AtomicIsEventSetLogicNoSpinNoLock()) { bool bStatus {}; EventBits bits; diff --git a/Source/Threading/Primitives/AuSemaphore.Linux.cpp b/Source/Threading/Primitives/AuSemaphore.Linux.cpp index 562f35ab..de095d34 100644 --- a/Source/Threading/Primitives/AuSemaphore.Linux.cpp +++ b/Source/Threading/Primitives/AuSemaphore.Linux.cpp @@ -101,10 +101,7 @@ namespace Aurora::Threading::Primitives AuAtomicAdd(&this->dwSleeping_, 1u); - auto old = this->dwState_; - //!tryLock (with old in a scope we can access) - while (!((old != 0) && - (AuAtomicCompareExchange(&this->dwState_, old - 1, old) == old))) + while (!this->TryLockNoSpin()) { if (uTimeout != 0) {