8#if !ALIB_SINGLE_THREADED
104 "Promise not fulfilled on destruction." )
106 "Promise not awaited on destruction." )
136 "Promise was already fulfilled. Repeated calls not allowed.\n Fullfilled at: "
144 "Promise was already fulfilled. Repeated calls not allowed.\n Fullfilled at: "
165 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
173 while (
future.wait_for( (waitDuration - waitTimer.
Age()).Export() )
174 != std::future_status::ready )
176 if ( waitTimer.
Age() < waitDuration )
179 assert::Raise( ci, 1,
"THREADS",
"Waiting for a Promise since (ms): ",
180 int(overallTimer.
Age().InAbsoluteMilliseconds()));
200 State WaitFor(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
202 return future.wait_for(maxWaitTimeSpan) == std::future_status::timeout
210 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
213 if (
future.wait_for(maxWaitTimeSpan) == std::future_status::timeout )
233 {
return WaitFor( maxWaitTimeSpan.Export(), ci ); }
236 {
return WaitFor( maxWaitTimeSpan.Export() ); }
250 return future.wait_until(wakeUpTime.
Export()) == std::future_status::timeout
258 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
261 if (
future.wait_until(wakeUpTime.
Export()) == std::future_status::timeout )
void Fulfill(const CallerInfo &ci, State state=State::OK)
lang::CallerInfo DbgFulfillCI
void DbgOmitDestructionWarning()
State Wait(const CallerInfo &ci)
lang::CallerInfo DbgWaitCI
Ticks::Duration DbgWaitTimeLimit
@ Unfulfilled
The state after construction.
@ Error
A default error state. (Use-case dependent.)
@ OK
The default state of successful fulfillment.
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.
State WaitFor(const Ticks::Duration &maxWaitTimeSpan, const CallerInfo &ci)
std::promise< State > promise
Used for implementation.
TTimePoint Export() const
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
void Raise(const lang::CallerInfo &ci, int type, std::string_view domain, TArgs &&... args)
threads::Promise Promise
Type alias in namespace alib.
lang::CallerInfo CallerInfo
Type alias in namespace alib.
time::Ticks Ticks
Type alias in namespace alib.
const char * File
The name of the source file as given by compiler.