8#if !ALIB_SINGLE_THREADED
77template<
typename TDerived>
88 TDerived&
cast() {
return static_cast<TDerived&
>(*this); }
125 "Acquire: Multiple acquirements of TCondition are forbidden." );
132 "Acquire: Owner is (still) set, after std::mutex.lock()." );
152 "Release: Ownership is with a different thread" );
174 "ReleaseAndNotify called without prior acquisition" );
177 "ReleaseAndNotify: Ownership is with a different thread" );
197 "An exclusive waiter is set. Thus, notifying 'all' is not allowed.");
200 "ReleaseAndNotify called without prior acquisition" );
203 "ReleaseAndNotify: Ownership is with a different thread" );
228 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
229 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
232 "WaitForNotification called without prior acquisition" );
235 "WaitForNotification: Ownership is with a different thread" );
242 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
267 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
268 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
271 "WaitForNotification called without prior acquisition" );
274 "WaitForNotification: Ownership is with a different thread" );
281 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
323 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
324 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
327 "WaitForNotification called without prior acquisition" );
330 "WaitForNotification: Ownership is with a different thread" );
338 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
340 [
this]{ return cast().isConditionMet(); } );
432 void Wait(
const Ticks::Duration::TDuration& maxWaitTimeSpan,
const CallerInfo& ci )
440 void Wait(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
443 WaitForNotification(maxWaitTimeSpan);
461 {
Wait( maxWaitTimeSpan.Export(), ci ); }
463 void Wait(
const Ticks::Duration& maxWaitTimeSpan )
464 { Wait( maxWaitTimeSpan.Export() ); }
487 void Wait(
const Ticks& wakeUpTime )
490 WaitForNotification(wakeUpTime);
498template<
typename T=
bool>
Condition(const character *dbgName)
void Notify(ALIB_DBG_TAKE_CI)
bool notified
Boolean member which records notifications. Defaults to not-notified.
void NotifyAll(ALIB_DBG_TAKE_CI)
void Wait(const Ticks::Duration::TDuration &maxWaitTimeSpan, const CallerInfo &ci)
void Wait(const Ticks &wakeUpTime, const CallerInfo &ci)
void Wait(const Ticks::Duration &maxWaitTimeSpan, const CallerInfo &ci)
void Wait(ALIB_DBG_TAKE_CI)
static Thread * GetCurrent()
static ALIB_DLL Thread * Get(std::thread::id nativeID)
TTimePoint Export() const
constexpr bool IsNotNull(const T &t)
constexpr bool IsNull(const T &t)
threads::TCondition< T > TCondition
Type alias in namespace alib.
lang::CallerInfo CallerInfo
Type alias in namespace alib.
time::Ticks Ticks
Type alias in namespace alib.
threads::Condition Condition
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
std::thread::id ThreadID
The ID of the calling thread.
void WaitForNotification(ALIB_DBG_TAKE_CI)
void ReleaseAndNotifyAll(ALIB_DBG_TAKE_CI)
TCondition(const character *dbgName)
std::condition_variable conditionVariable
void Release(ALIB_DBG_TAKE_CI)
void Acquire(ALIB_DBG_TAKE_CI)
void WaitForNotification(const Ticks::Duration &maxWaitTimeSpan, const CallerInfo &ci)
void WaitForNotification(const Ticks::Duration::TDuration &maxWaitTimeSpan, const CallerInfo &ci)
void ReleaseAndNotify(ALIB_DBG_TAKE_CI)