8#if !ALIB_SINGLE_THREADED
84template<
typename TDerived>
95 TDerived&
cast() {
return static_cast<TDerived&
>(*this); }
129 "Acquire: Multiple acquirements of TCondition are forbidden." );
136 "Acquire: Owner is (still) set, after std::mutex.lock()." );
153 "Release: Ownership is with a different thread" );
172 "ReleaseAndNotify called without prior acquisition" );
175 "ReleaseAndNotify: Ownership is with a different thread" );
192 "An exclusive waiter is set. Thus, notifying 'all' is not allowed.");
195 "ReleaseAndNotify called without prior acquisition" );
198 "ReleaseAndNotify: Ownership is with a different thread" );
220 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
221 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
224 "WaitForNotification called without prior acquisition" );
227 "WaitForNotification: Ownership is with a different thread" );
234 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
257 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
258 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
261 "WaitForNotification called without prior acquisition" );
264 "WaitForNotification: Ownership is with a different thread" );
271 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
308 ||
Dbg.AssertExclusiveWaiter == std::this_thread::get_id(),
ALIB_CALLER, ci,
309 "WaitForNotification called by a different thread than granted with 'Dbg.AssertExclusiveWaiter'.");
312 "WaitForNotification called without prior acquisition" );
315 "WaitForNotification: Ownership is with a different thread" );
323 std::unique_lock<std::mutex> lock(
mutex, std::adopt_lock);
325 [
this]{ return cast().isConditionMet(); } );
437 void Wait(
const Ticks::Duration::TDuration& maxWaitTimeSpan,
const CallerInfo& ci ) {
454 void Wait(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
456 WaitForNotification(maxWaitTimeSpan);
459 void ResetAndWait(
const Ticks::Duration::TDuration& maxWaitTimeSpan )
462 WaitForNotification(maxWaitTimeSpan);
477 {
Wait( maxWaitTimeSpan.Export(), ci ); }
486 void Wait(
const Ticks::Duration& maxWaitTimeSpan )
487 { Wait( maxWaitTimeSpan.Export() ); }
489 void ResetAndWait(
const Ticks::Duration& maxWaitTimeSpan )
490 { ResetAndWait( maxWaitTimeSpan.Export() ); }
522 void Wait(
const Ticks& wakeUpTime )
524 WaitForNotification(wakeUpTime);
527 void ResetAndWait(
const Ticks& wakeUpTime )
530 WaitForNotification(wakeUpTime);
538template<
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)