8#if !ALIB_SINGLE_THREADED
84template<
typename TDerived>
94 TDerived&
cast() {
return static_cast<TDerived&
>(*this); }
128 "Acquire: Multiple acquirements of TCondition are forbidden." );
135 "Acquire: Owner is (still) set, after std::mutex.lock()." );
137 Dbg.Acq.ActionNo=
Dbg.ActionCounter.fetch_add(1);
153 "Release: Ownership is with a different thread" );
155 Dbg.Rel.ActionNo=
Dbg.ActionCounter.fetch_add(1);
173 "ReleaseAndNotify called without prior acquisition" );
176 "ReleaseAndNotify: Ownership is with a different thread" );
180 Dbg.Notify.ActionNo=
Dbg.ActionCounter.fetch_add(1);
195 "An exclusive waiter is set. Thus, notifying 'all' is not allowed.");
198 "ReleaseAndNotify called without prior acquisition" );
201 "ReleaseAndNotify: Ownership is with a different thread" );
205 Dbg.Notify.ActionNo=
Dbg.ActionCounter.fetch_add(1);
224 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
225 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
228 "WaitForNotification called without prior acquisition" );
231 "WaitForNotification: Ownership is with a different thread" );
235 Dbg.Wait.ActionNo=
Dbg.ActionCounter.fetch_add(1);
239 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
262 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
263 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
266 "WaitForNotification called without prior acquisition" );
269 "WaitForNotification: Ownership is with a different thread" );
273 Dbg.Wait.ActionNo=
Dbg.ActionCounter.fetch_add(1);
277 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
314 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
315 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
318 "WaitForNotification called without prior acquisition" );
321 "WaitForNotification: Ownership is with a different thread" );
326 Dbg.Wait.ActionNo=
Dbg.ActionCounter.fetch_add(1);
330 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
332 [
this]{ return cast().isConditionMet(); } );
443 void Wait(
const Ticks::Duration::TDuration& maxWaitTimeSpan,
const CallerInfo& ci ) {
460 void Wait(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
462 WaitForNotification(maxWaitTimeSpan);
465 void ResetAndWait(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
468 WaitForNotification(maxWaitTimeSpan);
483 {
Wait( maxWaitTimeSpan.Export(), ci ); }
492 void Wait(
const Ticks::Duration& maxWaitTimeSpan )
493 { Wait( maxWaitTimeSpan.Export() ); }
495 void ResetAndWait(
const Ticks::Duration& maxWaitTimeSpan )
496 { ResetAndWait( maxWaitTimeSpan.Export() ); }
528 void Wait(
const Ticks& wakeUpTime )
530 WaitForNotification(wakeUpTime);
533 void ResetAndWait(
const Ticks& wakeUpTime )
536 WaitForNotification(wakeUpTime);
544template<
typename T=
bool>
void SetAll(ALIB_DBG_TAKE_CI)
void Reset(ALIB_DBG_TAKE_CI)
bool notified
Boolean member which records notifications. Defaults to not-notified.
void ResetAndWait(const Ticks::Duration::TDuration &maxWaitTimeSpan, const CallerInfo &ci)
void ResetAndWait(const Ticks &wakeUpTime, const CallerInfo &ci)
void Set(ALIB_DBG_TAKE_CI)
void Wait(const Ticks &wakeUpTime, const CallerInfo &ci)
void ResetAndWait(const Ticks::Duration &maxWaitTimeSpan, const CallerInfo &ci)
void Wait(ALIB_DBG_TAKE_CI)
void Wait(const Ticks::Duration::TDuration &maxWaitTimeSpan, const CallerInfo &ci)
Event(const character *dbgName)
void ResetAndWait(ALIB_DBG_TAKE_CI)
void Wait(const Ticks::Duration &maxWaitTimeSpan, const CallerInfo &ci)
static Thread * GetCurrent()
static Thread * Get(std::thread::id nativeID)
TTimePoint Export() const
constexpr bool IsNull(const T &t)
constexpr bool IsNotNull(const T &t)
threads::TCondition< T > TCondition
Type alias in namespace #"%alib".
threads::Event Event
Type alias in namespace #"%alib".
lang::CallerInfo CallerInfo
Type alias in namespace #"%alib".
time::Ticks Ticks
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)
void WaitForNotification(const Ticks &wakeUpTime, const CallerInfo &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)