[+] AuThreading::TryWait

This commit is contained in:
Reece Wilson 2023-09-12 18:47:25 +01:00
parent 8e54071d60
commit bf03124f92
2 changed files with 15 additions and 1 deletions

View File

@ -14,6 +14,7 @@ namespace Aurora::Threading
AUKN_SYM bool YieldPollNs(bool bPermitMultipleContextSwitches, AuUInt64 qwAbsTimeoutNs, PollCallback_cb cb);
AUKN_SYM bool WaitForAbsNS(IWaitable *pWaitable, AuUInt64 qwAbsTimeout = 0);
AUKN_SYM bool TryWait(IWaitable *pWaitable);
static const auto kWaitForFlagTimeoutIsNanoseconds = 1ul;
static const auto kWaitForFlagTimeoutIsAbsolute = 1ul << 1;

View File

@ -88,7 +88,20 @@ namespace Aurora::Threading
return pWaitable->TryLock();
});
}
AUKN_SYM bool TryWait(IWaitable *pWaitable)
{
if (pWaitable->HasLockImplementation())
{
return pWaitable->TryLock();
}
return Primitives::DoTryIf([=]()
{
return pWaitable->TryLock();
});
}
AUKN_SYM bool WaitFor(const AuList<IWaitable *> &waitables, AuUInt32 uFlags, AuUInt64 uTimeout)
{
AU_DEBUG_MEMCRUNCH;