[+] AuFutexBarrier::EnterTimedEx
This commit is contained in:
parent
d123850ac0
commit
0f62b03da0
@ -35,6 +35,18 @@ namespace Aurora::Threading::Waitables
|
||||
return AuMakePair(bSuccess, bTimeout);
|
||||
}
|
||||
|
||||
inline AuPair<bool /* bSuccess */, bool /* bTimeOut */>
|
||||
EnterTimedEx(AuUInt64 uTimeoutAbsNS,
|
||||
AuVoidFunc callOnce)
|
||||
{
|
||||
bool bTimeout {}, bSuccess {};
|
||||
bSuccess = this->Park(bTimeout,
|
||||
true,
|
||||
uTimeoutAbsNS,
|
||||
callOnce);
|
||||
return AuMakePair(bSuccess, bTimeout);
|
||||
}
|
||||
|
||||
inline bool TryEnter()
|
||||
{
|
||||
return this->TryEnterNoSpin();
|
||||
@ -53,7 +65,11 @@ namespace Aurora::Threading::Waitables
|
||||
}
|
||||
|
||||
private:
|
||||
auline bool Park(bool &bTimedOut, bool bTakeOwnership, AuUInt64 uTimeoutAbsNS)
|
||||
|
||||
auline bool Park(bool &bTimedOut,
|
||||
bool bTakeOwnership,
|
||||
AuUInt64 uTimeoutAbsNS,
|
||||
AuVoidFunc callOnce = {})
|
||||
{
|
||||
static const AuUInt32 kRef { 0 };
|
||||
|
||||
@ -61,7 +77,7 @@ namespace Aurora::Threading::Waitables
|
||||
|
||||
if (bTakeOwnership)
|
||||
{
|
||||
if (!this->TryEnterNoSpin())
|
||||
if (!this->TryEnterNoSpin(callOnce))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -93,7 +109,7 @@ namespace Aurora::Threading::Waitables
|
||||
return true;
|
||||
}
|
||||
|
||||
auline bool TryEnterNoSpin()
|
||||
auline bool TryEnterNoSpin(AuVoidFunc callOnce = {})
|
||||
{
|
||||
AuUInt32 uState;
|
||||
|
||||
@ -103,6 +119,11 @@ namespace Aurora::Threading::Waitables
|
||||
{
|
||||
if (uState == 1)
|
||||
{
|
||||
if (callOnce)
|
||||
{
|
||||
callOnce();
|
||||
}
|
||||
|
||||
AuAtomicStore(&this->uAtomicState, 1u);
|
||||
WakeAllOnAddress((const void *)&this->uAtomicState);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user