8#if !ALIB_SINGLE_THREADED
100 "Promise not fulfilled on destruction." )
102 "Promise not awaited on destruction." )
132 "Promise was already fulfilled. Repeated calls not allowed.\n Fullfilled at: "
140 "Promise was already fulfilled. Repeated calls not allowed.\n Fullfilled at: "
161 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
169 while (
future.wait_for( (waitDuration - waitTimer.
Age()).Export() )
170 != std::future_status::ready )
172 if ( waitTimer.
Age() < waitDuration )
175 assert::Raise( ci, 1,
"THREADS",
"Waiting for a Promise since (ms): ",
176 int(overallTimer.
Age().InAbsoluteMilliseconds()));
196 State WaitFor(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
198 return future.wait_for(maxWaitTimeSpan) == std::future_status::timeout
206 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
209 if (
future.wait_for(maxWaitTimeSpan) == std::future_status::timeout )
229 {
return WaitFor( maxWaitTimeSpan.Export(), ci ); }
232 {
return WaitFor( maxWaitTimeSpan.Export() ); }
246 return future.wait_until(wakeUpTime.
Export()) == std::future_status::timeout
254 "Promise was already awaited. Repeated calls not allowed.\n Awaited at: "
257 if (
future.wait_until(wakeUpTime.
Export()) == std::future_status::timeout )
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
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.
State WaitFor(const Ticks::Duration &maxWaitTimeSpan, const CallerInfo &ci)
std::promise< State > promise
Used for implementation.
TTimePoint Export() const
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.