Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
UseCondVar Class Reference

Wrapper class for POSIX condition variables. More...

#include <useCondVar.H>

Public Member Functions

 UseCondVar (pthread_cond_t *c, pthread_mutex_t *m)
 Construct wrapper for condition variable and mutex.
 
int wait ()
 Wait for the condition variable to be signaled.
 
int signal ()
 Signal one waiting thread.
 
int broadcast ()
 Wake all waiting threads.
 
 ~UseCondVar ()
 Destructor (does not destroy the condition variable)
 

Private Attributes

pthread_cond_t * cond
 
pthread_mutex_t * mutex
 

Detailed Description

Wrapper class for POSIX condition variables.

Provides a simple interface for pthread condition variable operations. Does not own the condition variable or mutex - they must be managed separately. *

Thread safety
Thread-safe only with external synchronization and correct mutex usage.

Definition at line 101 of file useCondVar.H.

Constructor & Destructor Documentation

◆ ~UseCondVar()

UseCondVar::~UseCondVar ( )
inline

Destructor (does not destroy the condition variable)

Definition at line 166 of file useCondVar.H.

Member Function Documentation

◆ broadcast()

int UseCondVar::broadcast ( )
inline

Wake all waiting threads.

Returns
0 on success, error code on failure *

Definition at line 159 of file useCondVar.H.

References cond.

◆ signal()

int UseCondVar::signal ( )
inline

Signal one waiting thread.

Returns
0 on success, error code on failure *

Definition at line 147 of file useCondVar.H.

References cond.

◆ wait()

int UseCondVar::wait ( )
inline

Wait for the condition variable to be signaled.

Returns
0 on success, error code on failure
Note
The mutex must be held when calling this function *

Definition at line 135 of file useCondVar.H.

References cond, and mutex.

Member Data Documentation

◆ cond

pthread_cond_t* UseCondVar::cond
private

Definition at line 105 of file useCondVar.H.

Referenced by UseCondVar(), broadcast(), signal(), and wait().

◆ mutex

pthread_mutex_t* UseCondVar::mutex
private

Definition at line 106 of file useCondVar.H.

Referenced by UseCondVar(), and wait().


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