8#if !ALIB_SINGLE_THREADED
102 "Promise not fulfilled on destruction." )
104 "Promise not awaited on destruction." )
133 "Promise was already fulfilled. Repeated calls not allowed.\n Fullfilled at: "
141 "Promise was already fulfilled. Repeated calls not allowed.\n Fullfilled at: "
162 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
170 while (
future.wait_for( (waitDuration - waitTimer.
Age()).Export() )
171 != std::future_status::ready )
173 if ( waitTimer.
Age() < waitDuration )
176 assert::Raise( ci, 1,
"THREADS",
"Waiting for a Promise since (ms): ",
177 int(overallTimer.
Age().InAbsoluteMilliseconds()));
197 State WaitFor(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
199 return future.wait_for(maxWaitTimeSpan) == std::future_status::timeout
207 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
210 if (
future.wait_for(maxWaitTimeSpan) == std::future_status::timeout )
230 {
return WaitFor( maxWaitTimeSpan.Export(), ci ); }
233 {
return WaitFor( maxWaitTimeSpan.Export() ); }
247 return future.wait_until(wakeUpTime.
Export()) == std::future_status::timeout
255 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
258 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.