/*** 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 { using PollCallback_cb = AuFunction; 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.
See: Mutex, CriticalSection, Semaphore, Event, Thread, Async, and others */ AUKN_SYM bool WaitFor(IWaitable *waitable, AuUInt64 timeout = 0); static bool WaitFor(std::atomic &value, AuUInt64 timeout = 0) { Waitables::BooleanWaitable waitable(value); return WaitFor(&waitable, timeout); } /*! Waits on a list of IWaitable objects.
See: Mutex, CriticalSection, Semaphore, Event, Thread, Async, and others
On timeout, returns false
On error, waitables are restored to their state at the point of WaitFors call */ AUKN_SYM bool WaitFor(const AuList &waitables, AuUInt64 timeout = 0); }