RR Thread Pool
 All Classes Functions Typedefs Groups Pages
Public Member Functions | List of all members
Cond Class Reference

Convenient adapter for class ICond. More...

#include <Cond.h>

Public Member Functions

 Cond ()
 Default constructor. More...
 
 Cond (ICond *icond)
 Creates a cond adapter from out of an abstract interface. More...
 
void wait (Mutex &mutex)
 The calling thread will wait until the condition variable is signaled by another thread. More...
 
void signal ()
 Resumes at least one single thread that is waiting for the condition. More...
 
void broadcast ()
 Resumes all threads that are waiting for the condition. More...
 
ICondinterface ()
 Returns the abstract interface used by the adapter.
 

Detailed Description

Convenient adapter for class ICond.

Note
This class is useful to write code that follow the design pattern
See Also
Resource Acquisition Is Initialization

Constructor & Destructor Documentation

Cond::Cond ( )
inline

Default constructor.

Builds a condition variable by calling the method ICond::create() and then hosts the returned abstract interface to destroy it during the object destruction.

Cond::Cond ( ICond icond)
inline

Creates a cond adapter from out of an abstract interface.

Parameters
icondObject implementing the abstract interface ICond.
Precondition
  1. Parameter icond is not null.

Member Function Documentation

void Cond::broadcast ( )
inline

Resumes all threads that are waiting for the condition.

Calling the method without no threads waiting for signals have no effect.

void Cond::signal ( )
inline

Resumes at least one single thread that is waiting for the condition.

Calling the method without no threads waiting for signals have no effect.

void Cond::wait ( Mutex mutex)
inline

The calling thread will wait until the condition variable is signaled by another thread.

This method atomically performs this steps:

  • unlocks the passed mutex.
  • wait for a signal from another thread (see methods signal and broadcast).
  • locks again the mutex.
Parameters
mutexThe mutex to be unlocked/locked.
Precondition
  1. The passed mutex is currently locked by the calling thread.
Postcondition
  1. The passed mutex is locked back by the calling thread.

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