ORIGINAL
Loading...
Searching...
No Matches
original::pCondition Class Referencefinal

POSIX condition variable implementation. More...

#include <condition.h>

Inheritance diagram for original::pCondition:
Inheritance graph
Collaboration diagram for original::pCondition:
Collaboration graph

Public Member Functions

 pCondition ()
 Constructs and initializes the condition variable.
 
void wait (mutexBase &mutex) override
 Waits for notification while holding the mutex.
 
bool waitFor (mutexBase &mutex, time::duration d) override
 Waits for notification with timeout.
 
void notify () override
 Notifies one waiting thread.
 
void notifyAll () override
 Notifies all waiting threads.
 
 ~pCondition () override
 Destroys the condition variable.
 
template<typename Pred >
void wait (mutexBase &mutex, Pred predicate) noexcept(noexcept(predicate()))
 Waits until predicate becomes true.
 
template<typename Pred >
bool waitFor (mutexBase &mutex, const time::duration &d, Pred predicate) noexcept(noexcept(predicate()))
 Waits with timeout until predicate becomes true.
 
- Public Member Functions inherited from original::conditionBase
 conditionBase ()=default
 Default constructor.
 
template<typename Pred >
void wait (mutexBase &mutex, Pred predicate) noexcept(noexcept(predicate()))
 Waits until predicate becomes true.
 
template<typename Pred >
bool waitFor (mutexBase &mutex, const time::duration &d, Pred predicate) noexcept(noexcept(predicate()))
 Waits with timeout until predicate becomes true.
 
virtual ~conditionBase ()=default
 Virtual destructor.
 
 conditionBase (const conditionBase &)=delete
 Deleted copy constructor.
 
conditionBaseoperator= (const conditionBase &)=delete
 Deleted copy assignment operator.
 

Detailed Description

POSIX condition variable implementation.

Wrapper around pthread_cond_t with RAII semantics. Provides thread synchronization using POSIX condition variables.

Constructor & Destructor Documentation

◆ pCondition()

original::pCondition::pCondition ( )
inlineexplicit

Constructs and initializes the condition variable.

Exceptions
sysErrorif initialization fails

◆ ~pCondition()

original::pCondition::~pCondition ( )
inlineoverride

Destroys the condition variable.

Note
Calls pthread_cond_destroy()

Member Function Documentation

◆ notify()

void original::pCondition::notify ( )
inlineoverridevirtual

Notifies one waiting thread.

Exceptions
sysErrorif notification fails

Implements original::conditionBase.

◆ notifyAll()

void original::pCondition::notifyAll ( )
inlineoverridevirtual

Notifies all waiting threads.

Exceptions
sysErrorif notification fails

Implements original::conditionBase.

◆ wait() [1/2]

void original::pCondition::wait ( mutexBase & mutex)
inlineoverridevirtual

Waits for notification while holding the mutex.

Parameters
mutexLocked mutex to wait on
Exceptions
sysErrorif wait operation fails
valueErrorif mutex is not a pMutex

Implements original::conditionBase.

◆ wait() [2/2]

template<typename Pred >
void original::conditionBase::wait ( mutexBase & mutex,
Pred predicate )
noexcept

Waits until predicate becomes true.

Template Parameters
PredPredicate type (must be callable and return bool)
Parameters
mutexLocked mutex to wait on
predicateCondition predicate to check
Exceptions
sysErrorif wait operation fails
Note
Implements the "wait with predicate" pattern to avoid spurious wakeups

◆ waitFor() [1/2]

template<typename Pred >
bool original::conditionBase::waitFor ( mutexBase & mutex,
const time::duration & d,
Pred predicate )
noexcept

Waits with timeout until predicate becomes true.

Template Parameters
PredPredicate type (must be callable and return bool)
Parameters
mutexLocked mutex to wait on
dMaximum duration to wait
predicateCondition predicate to check
Returns
true if predicate became true, false if timeout occurred
Exceptions
sysErrorif wait operation fails

◆ waitFor() [2/2]

bool original::pCondition::waitFor ( mutexBase & mutex,
time::duration d )
inlineoverridevirtual

Waits for notification with timeout.

Parameters
mutexLocked mutex to wait on
dMaximum duration to wait
Returns
true if notified, false if timeout occurred
Exceptions
sysErrorif wait operation fails
valueErrorif mutex is not a pMutex

Implements original::conditionBase.


The documentation for this class was generated from the following file: