Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
useCondVar.H File Reference

Legacy wrapper class for POSIX condition variables. More...

#include <pthread.h>
Include dependency graph for useCondVar.H:

Go to the source code of this file.

Classes

class  UseCondVar
 Legacy wrapper class for POSIX condition variables. More...
 

Detailed Description

Legacy wrapper class for POSIX condition variables.

This file provides a simple legacy C++ wrapper around pthread condition variables, offering a cleaner interface for thread synchronization.

Deprecated:
New code should generally prefer std::condition_variable or higher-level coordination helpers such as Aleph::bounded_channel<T> from concurrency_utils.H.

Features

  • Wait: Block until signaled
  • Signal: Wake one waiting thread
  • Broadcast: Wake all waiting threads

Usage Example

pthread_mutex_t mutex;
pthread_cond_t cond;
pthread_mutex_init(&mutex, nullptr);
pthread_cond_init(&cond, nullptr);
// In waiting thread:
{
UseMutex lock(&mutex);
UseCondVar cv(&cond, &mutex);
while (!condition_met)
cv.wait();
}
// In signaling thread:
{
UseMutex lock(&mutex);
condition_met = true;
UseCondVar cv(&cond, &mutex);
cv.signal();
}
Legacy wrapper class for POSIX condition variables.
Definition useCondVar.H:109
Legacy RAII-style mutex lock guard.
Definition useMutex.H:151
Note
Always hold the associated mutex when calling wait/signal/broadcast.
Legacy POSIX wrapper kept for backward compatibility. Prefer std::condition_variable or concurrency_utils.H in new code.
See also
useMutex.H For the companion mutex wrapper
Author
Leandro Rabindranath León *

Definition in file useCondVar.H.