diff --git a/Source/Threading/AuWakeInternal.hpp b/Source/Threading/AuWakeInternal.hpp index 710ca875..02d08f67 100644 --- a/Source/Threading/AuWakeInternal.hpp +++ b/Source/Threading/AuWakeInternal.hpp @@ -10,11 +10,21 @@ namespace Aurora::Threading { + // Buttered up native high-res wait for change API: bool InternalLTSWaitOnAddressHighRes(void *pTargetAddress, const void *pCompareAddress, AuUInt8 uWordSize, AuUInt64 qwNanosecondsAbs); + // ...cont + void InternalLTSWakeAll(const void *pTargetAddress); + + // ...cont + void InternalLTSWakeOne(const void *pTargetAddress); + + // extra wrapping for use with primitives when expecting less scheduler indirection + // (its good to avoid the emulation layer in the slow paths of high level primitives) + static bool InternalLTSWaitOnAddressHighRes(volatile void *pTargetAddress, const void *pCompareAddress, AuUInt8 uWordSize, diff --git a/Source/Threading/AuWakeOnAddress.cpp b/Source/Threading/AuWakeOnAddress.cpp index a11b0e6e..84f61b03 100644 --- a/Source/Threading/AuWakeOnAddress.cpp +++ b/Source/Threading/AuWakeOnAddress.cpp @@ -795,6 +795,18 @@ namespace Aurora::Threading } } + void InternalLTSWakeAll(const void *pTargetAddress) + { + auto [pWakeAddress, uDelta, uMask] = DecodeAddress(pTargetAddress, 1); + RunOSWakeAllOnAddress(pWakeAddress); + } + + void InternalLTSWakeOne(const void *pTargetAddress) + { + auto [pWakeAddress, uDelta, uMask] = DecodeAddress(pTargetAddress, 1); + RunOSWakeNOnAddress(pWakeAddress, uDelta ? INT_MAX : 1); + } + AUKN_SYM bool WaitOnAddress(const void *pTargetAddress, const void *pCompareAddress, AuUInt8 uWordSize, diff --git a/Source/Threading/Primitives/AuConditionMutex.NT.cpp b/Source/Threading/Primitives/AuConditionMutex.NT.cpp index ac35c27d..02f8bdb8 100644 --- a/Source/Threading/Primitives/AuConditionMutex.NT.cpp +++ b/Source/Threading/Primitives/AuConditionMutex.NT.cpp @@ -126,7 +126,7 @@ namespace Aurora::Threading::Primitives { if (AuAtomicCompareExchange(&uValueRef, uValue - kFutexBitWait, uValue) == uValue) { - pWakeByAddressSingle((void *)&uValueRef); + InternalLTSWakeOne((void *)&uValueRef); return; } } diff --git a/Source/Threading/Primitives/AuConditionVariable.NT.cpp b/Source/Threading/Primitives/AuConditionVariable.NT.cpp index ef7db76d..58308d96 100644 --- a/Source/Threading/Primitives/AuConditionVariable.NT.cpp +++ b/Source/Threading/Primitives/AuConditionVariable.NT.cpp @@ -118,7 +118,7 @@ namespace Aurora::Threading::Primitives } AuUInt8 uBlockBit { 1 }; - pWakeByAddressAll((void *)&this->wlist); // this is kinda sad + InternalLTSWakeAll((void *)&this->wlist); // this is kinda sad bRet = InternalLTSWaitOnAddressHighRes(&this->wlist, &uBlockBit, 1, uEndTimeSteady); // why? } else @@ -332,7 +332,7 @@ namespace Aurora::Threading::Primitives { if (gUseNativeWaitCondvar) { - pWakeByAddressSingle((void *)&this->wlist); + InternalLTSWakeOne((void *)&this->wlist); } else { @@ -376,7 +376,7 @@ namespace Aurora::Threading::Primitives expected - uAwoken, original) == original) { - pWakeByAddressAll((void *)&this->wlist); + InternalLTSWakeAll((void *)&this->wlist); return; } else diff --git a/Source/Threading/Primitives/AuMutex.NT.cpp b/Source/Threading/Primitives/AuMutex.NT.cpp index eb16987b..e726499b 100644 --- a/Source/Threading/Primitives/AuMutex.NT.cpp +++ b/Source/Threading/Primitives/AuMutex.NT.cpp @@ -255,7 +255,7 @@ namespace Aurora::Threading::Primitives if (AuAtomicCompareExchange(&uValueRef, uValue - kFutexBitWait, uValue) == uValue) { - pWakeByAddressSingle((void *)&this->state_); + InternalLTSWakeOne((void *)&this->state_); return; } @@ -327,7 +327,7 @@ namespace Aurora::Threading::Primitives { if (AuAtomicCompareExchange(&uValueRef, uValue - kFutexBitWait, uValue) == uValue) { - pWakeByAddressSingle((void *)&this->state_); + InternalLTSWakeOne((void *)&this->state_); return; } } diff --git a/Source/Threading/Primitives/AuSemaphore.NT.cpp b/Source/Threading/Primitives/AuSemaphore.NT.cpp index 61e80c95..362af1b0 100644 --- a/Source/Threading/Primitives/AuSemaphore.NT.cpp +++ b/Source/Threading/Primitives/AuSemaphore.NT.cpp @@ -221,11 +221,11 @@ namespace Aurora::Threading::Primitives { if (count == 1) { - pWakeByAddressSingle((void *)&this->dwState_); + InternalLTSWakeOne((void *)&this->dwState_); } else { - pWakeByAddressAll((void *)&this->dwState_); + InternalLTSWakeAll((void *)&this->dwState_); } } }