[*] ...and same applies to RWLock

(instead its pls dont use the public api instead of the internal NT apis)
This commit is contained in:
Reece Wilson 2023-09-09 12:39:47 +01:00
parent 9601fcfd39
commit 109b0cff3f
3 changed files with 22 additions and 12 deletions

View File

@ -11,7 +11,7 @@
namespace Aurora::Threading namespace Aurora::Threading
{ {
// Buttered up native high-res wait for change API: // Buttered up native high-res wait for change API:
bool InternalLTSWaitOnAddressHighRes(void *pTargetAddress, bool InternalLTSWaitOnAddressHighRes(const void *pTargetAddress,
const void *pCompareAddress, const void *pCompareAddress,
AuUInt8 uWordSize, AuUInt8 uWordSize,
AuUInt64 qwNanosecondsAbs); AuUInt64 qwNanosecondsAbs);
@ -22,14 +22,17 @@ namespace Aurora::Threading
// ...cont // ...cont
void InternalLTSWakeOne(const void *pTargetAddress); void InternalLTSWakeOne(const void *pTargetAddress);
// ...cont
void InternalLTSWakeCount(const void *pTargetAddress, AuUInt32 uCount);
// extra wrapping for use with primitives when expecting less scheduler indirection // 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) // (its good to avoid the emulation layer in the slow paths of high level primitives)
static bool InternalLTSWaitOnAddressHighRes(volatile void *pTargetAddress, static bool InternalLTSWaitOnAddressHighRes(volatile const void *pTargetAddress,
const void *pCompareAddress, const void *pCompareAddress,
AuUInt8 uWordSize, AuUInt8 uWordSize,
AuUInt64 qwNanosecondsAbs) AuUInt64 qwNanosecondsAbs)
{ {
return InternalLTSWaitOnAddressHighRes((void *)pTargetAddress, pCompareAddress, uWordSize, qwNanosecondsAbs); return InternalLTSWaitOnAddressHighRes((const void *)pTargetAddress, pCompareAddress, uWordSize, qwNanosecondsAbs);
} }
} }

View File

@ -768,7 +768,7 @@ namespace Aurora::Threading
// it does work on Linux and Windows 8+ // it does work on Linux and Windows 8+
// it does not, however, work on emulated platforms // it does not, however, work on emulated platforms
// this is intentional // this is intentional
bool InternalLTSWaitOnAddressHighRes(void *pTargetAddress, bool InternalLTSWaitOnAddressHighRes(const void *pTargetAddress,
const void *pCompareAddress, const void *pCompareAddress,
AuUInt8 uWordSize, AuUInt8 uWordSize,
AuUInt64 qwNanosecondsAbs) AuUInt64 qwNanosecondsAbs)
@ -807,6 +807,12 @@ namespace Aurora::Threading
RunOSWakeNOnAddress(pWakeAddress, uDelta ? INT_MAX : 1); RunOSWakeNOnAddress(pWakeAddress, uDelta ? INT_MAX : 1);
} }
void InternalLTSWakeCount(const void *pTargetAddress, AuUInt32 uCount)
{
auto [pWakeAddress, uDelta, uMask] = DecodeAddress(pTargetAddress, 1);
RunOSWakeNOnAddress(pWakeAddress, uDelta ? INT_MAX : uCount);
}
AUKN_SYM bool WaitOnAddress(const void *pTargetAddress, AUKN_SYM bool WaitOnAddress(const void *pTargetAddress,
const void *pCompareAddress, const void *pCompareAddress,
AuUInt8 uWordSize, AuUInt8 uWordSize,

View File

@ -9,6 +9,7 @@
//#define RWLOCK_VIEW_HAS_PARENT //#define RWLOCK_VIEW_HAS_PARENT
#include "AuRWLock.hpp" #include "AuRWLock.hpp"
#include "SMTYield.hpp" #include "SMTYield.hpp"
#include "../AuWakeInternal.hpp"
namespace Aurora::Threading::Primitives namespace Aurora::Threading::Primitives
{ {
@ -166,7 +167,7 @@ namespace Aurora::Threading::Primitives
{ {
if (gUseFutexRWLock) if (gUseFutexRWLock)
{ {
if (!WaitOnAddressSteady((const void *)&this->state_, &iCurState, sizeof(iCurState), uTimeout)) if (!InternalLTSWaitOnAddressHighRes((const void *)&this->state_, &iCurState, sizeof(iCurState), uTimeout))
{ {
return false; return false;
} }
@ -232,7 +233,7 @@ namespace Aurora::Threading::Primitives
{ {
if (gUseFutexRWLock) if (gUseFutexRWLock)
{ {
if (!WaitOnAddressSteady((const void *)&this->state_, &iCurState, sizeof(iCurState), uEndTime)) if (!InternalLTSWaitOnAddressHighRes((const void *)&this->state_, &iCurState, sizeof(iCurState), uEndTime))
{ {
return false; return false;
} }
@ -424,7 +425,7 @@ namespace Aurora::Threading::Primitives
while ((iCurState = AuAtomicLoad(&this->state_)) != 0) while ((iCurState = AuAtomicLoad(&this->state_)) != 0)
{ {
static const AuUInt32 kExpect { 0 }; static const AuUInt32 kExpect { 0 };
if (!WaitOnAddressSteady(pSemaphore, &kExpect, sizeof(kExpect), qwTimeoutNS)) if (!InternalLTSWaitOnAddressHighRes(pSemaphore, &kExpect, sizeof(kExpect), qwTimeoutNS))
{ {
break; break;
} }
@ -503,7 +504,7 @@ namespace Aurora::Threading::Primitives
{ {
if (gUseFutexRWLock) if (gUseFutexRWLock)
{ {
WakeOnAddress((const void *)&this->state_); InternalLTSWakeOne((const void *)&this->state_);
} }
else else
{ {
@ -518,7 +519,7 @@ namespace Aurora::Threading::Primitives
{ {
auto pThat = this->GetFutexConditionWriter(); auto pThat = this->GetFutexConditionWriter();
AuAtomicAdd(pThat, 1u); AuAtomicAdd(pThat, 1u);
WakeOnAddress(pThat); InternalLTSWakeOne(pThat);
} }
else else
{ {
@ -531,7 +532,7 @@ namespace Aurora::Threading::Primitives
{ {
if (gUseFutexRWLock) if (gUseFutexRWLock)
{ {
WakeAllOnAddress((const void *)&this->state_); InternalLTSWakeAll((const void *)&this->state_);
} }
else else
{ {
@ -547,7 +548,7 @@ namespace Aurora::Threading::Primitives
auto pThat = this->GetFutexConditionWriter(); auto pThat = this->GetFutexConditionWriter();
AuUInt32 uCount = AuAtomicLoad(&this->writersPending_); AuUInt32 uCount = AuAtomicLoad(&this->writersPending_);
AuAtomicAdd(pThat, uCount); AuAtomicAdd(pThat, uCount);
WakeNOnAddress(pThat, uCount); InternalLTSWakeCount(pThat, uCount);
} }
else else
{ {
@ -843,7 +844,7 @@ namespace Aurora::Threading::Primitives
} }
else else
{ {
bStatus = WaitOnAddressSteady(pSemaphore, &kExpect, sizeof(kExpect), uEndTime); bStatus = InternalLTSWaitOnAddressHighRes(pSemaphore, &kExpect, sizeof(kExpect), uEndTime);
} }
AuAtomicSub(&this->writersPending_, 1); AuAtomicSub(&this->writersPending_, 1);