ORIGINAL
Loading...
Searching...
No Matches
original::conditionBase Class Referenceabstract

Abstract base class for condition variable implementations. More...

#include <condition.h>

Inheritance diagram for original::conditionBase:
Inheritance graph
Collaboration diagram for original::conditionBase:
Collaboration graph

Public Member Functions

 conditionBase ()=default
 Default constructor.
 
virtual void wait (mutexBase &mutex)=0
 Waits for notification while holding the mutex.
 
virtual bool waitFor (mutexBase &mutex, time::duration d)=0
 Waits for notification with timeout.
 
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 void notify ()=0
 Notifies one waiting thread.
 
virtual void notifyAll ()=0
 Notifies all waiting threads.
 
virtual ~conditionBase ()=default
 Virtual destructor.
 
 conditionBase (const conditionBase &)=delete
 Deleted copy constructor.
 
conditionBaseoperator= (const conditionBase &)=delete
 Deleted copy assignment operator.
 

Detailed Description

Abstract base class for condition variable implementations.

Provides the interface for thread synchronization operations:

  • Waiting with mutex protection
  • Timed waiting with duration support
  • Notification of waiting threads
  • Predicate-based waiting templates
Note
This is an abstract base class and cannot be instantiated directly. Derived classes must implement all pure virtual methods.

Member Function Documentation

◆ notify()

virtual void original::conditionBase::notify ( )
pure virtual

Notifies one waiting thread.

Exceptions
sysErrorif notification fails

Implemented in original::pCondition.

◆ notifyAll()

virtual void original::conditionBase::notifyAll ( )
pure virtual

Notifies all waiting threads.

Exceptions
sysErrorif notification fails

Implemented in original::pCondition.

◆ wait() [1/2]

virtual void original::conditionBase::wait ( mutexBase & mutex)
pure virtual

Waits for notification while holding the mutex.

Parameters
mutexLocked mutex to wait on
Exceptions
sysErrorif wait operation fails
Note
The mutex must be locked by the calling thread

Implemented in original::pCondition.

◆ 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]

virtual bool original::conditionBase::waitFor ( mutexBase & mutex,
time::duration d )
pure virtual

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
Note
The mutex must be locked by the calling thread

Implemented in original::pCondition.


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