[+] bool AuFutexSemaphore::LockUntilEqualAbsNS(AuUInt32 uValue, AuOptional<AuUInt64> qwTimeoutAbs)

This commit is contained in:
Reece Wilson 2024-03-10 00:41:18 +00:00
parent 3c6d5a020b
commit cc4d97d6e7

View File

@ -156,6 +156,28 @@ namespace Aurora::Threading::Waitables
return true;
}
inline bool LockUntilEqualAbsNS(AuUInt32 uValue,
AuOptional<AuUInt64> qwTimeoutAbs)
{
const AuUInt32 kRef { uValue };
while (!TryWaitOnAddressUntilEqual((const void *)&this->uAtomicState, &kRef, sizeof(kRef)))
{
bool bStatus {};
AuAtomicAdd(&this->uAtomicSleeping, 1u);
bStatus = WaitOnAddressUntilEqualSteady((const void *)&this->uAtomicState, &kRef, sizeof(kRef), qwTimeoutAbs.ValueOr(0), true);
AuAtomicSub(&this->uAtomicSleeping, 1u);
if (!bStatus)
{
return TryWaitOnAddressUntilEqual((const void *)&this->uAtomicState, &kRef, sizeof(kRef));
}
}
return true;
}
AuAUInt32 uAtomicState {};
AuAUInt32 uAtomicSleeping {};
};