8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
16#if !ALIB_SINGLE_THREADED
17# include <condition_variable>
20#include <unordered_map>
36#if !ALIB_SINGLE_THREADED && ALIB_DEBUG && ALIB_STRINGS && !DOXYGEN
42 "Promise was already fulfilled. Repeated calls not allowed.\n"
53 "Promise was already awaited. Repeated calls not allowed.\n"
61 while (
future.wait_for( (waitDuration - waitTimer.Age()).Export() )
62 != std::future_status::ready )
64 if ( waitTimer.Age() < waitDuration )
67 ALIB_WARNING(
"THREADS",
"Waiting for a Promise since {}.", overallTimer.Age() )
78 "Promise was already awaited. Repeated calls not allowed.\n"
81 if (
future.wait_for(maxWaitTimeSpan) == std::future_status::timeout )
91 "Promise was already awaited. Repeated calls not allowed.\n"
94 if (
future.wait_until(wakeUpTime.Export()) == std::future_status::timeout )
void Fulfill(const CallerInfo &ci, State state=State::OK)
lang::CallerInfo DbgFulfillCI
State Wait(const CallerInfo &ci)
lang::CallerInfo DbgWaitCI
Ticks::Duration DbgWaitTimeLimit
@ Unfulfilled
The state after construction.
State WaitUntil(const Ticks &wakeUpTime, const CallerInfo &ci)
std::future< State > future
Used for implementation.
State WaitFor(const Ticks::Duration::TDuration &maxWaitTimeSpan, const CallerInfo &ci)
Promise()
Default constructor. Sets the state to State::Unfulfilled.
std::promise< State > promise
Used for implementation.
#define ALIB_WARNING(domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
lang::CallerInfo CallerInfo
Type alias in namespace alib.
time::Ticks Ticks
Type alias in namespace alib.