AuroraRuntime/Include/Aurora/Threading/WaitFor.hpp

36 lines
1.3 KiB
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: WaitFor.hpp
Date: 2021-6-10
Author: Reece
***/
#pragma once
namespace Aurora::Threading
{
2022-01-19 18:37:00 +00:00
using PollCallback_cb = AuFunction<bool()>;
2021-06-27 21:25:29 +00:00
AUKN_SYM bool YieldPollNs(bool permitMultipleContextSwitches, AuUInt64 timeoutNs, PollCallback_cb cb);
AUKN_SYM bool YieldPoll(bool permitMultipleContextSwitches, AuUInt64 timeoutMs, PollCallback_cb cb);
/*!
Waits for a list of IWaitable objects. <br>
See: Mutex, CriticalSection, Semaphore, Event, Thread, Async, and others
*/
AUKN_SYM bool WaitFor(IWaitable *waitable, AuUInt64 timeout = 0);
static bool WaitFor(std::atomic<bool> &value, AuUInt64 timeout = 0)
{
Waitables::BooleanWaitable waitable(value);
return WaitFor(&waitable, timeout);
}
/*!
Waits on a list of IWaitable objects. <br>
See: Mutex, CriticalSection, Semaphore, Event, Thread, Async, and others <br>
On timeout, returns false <br>
On error, waitables are restored to their state at the point of WaitFors call
*/
AUKN_SYM bool WaitFor(const AuList<IWaitable *> &waitables, AuUInt64 timeout = 0);
}