Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

Conditional Class Reference

A conditional variable synchcronization object for one to one and one to many signal and control events between processes. conditional. More...

#include <thread.h>

Inheritance diagram for Conditional:

Mutex Buffer FixedBuffer List of all members.

Public Member Functions

 Conditional (const char *id=NULL)
 Create an instance of a conditional.

virtual ~Conditional ()
 Destroy the conditional.

void signal (bool broadcast)
 Signal a conditional object and a waiting threads.

bool wait (timeout_t timer=0, bool locked=false)
 Wait to be signaled from another thread.


Detailed Description

A conditional variable synchcronization object for one to one and one to many signal and control events between processes. conditional.

Conditional variables may wait for and receive signals to notify when to resume or perform operations. Multiple waiting threads may be woken with a broadcast signal.

Warning:
While this class inherits from Mutex, the methods of the class Conditional just handle the system conditional variable, so the user is responsible for calling enterMutex and leaveMutex so as to avoid race conditions. Another thing to note is that if you have several threads waiting on one condition, not uncommon in thread pools, each thread must take care to manually unlock the mutex if cancellation occurs. Otherwise the first thread cancelled will deadlock the rest of the thread.
Author:
David Sugar

Todo:
implement in win32


Constructor & Destructor Documentation

Conditional::Conditional const char *  id = NULL  ) 
 

Create an instance of a conditional.

virtual Conditional::~Conditional  )  [virtual]
 

Destroy the conditional.


Member Function Documentation

void Conditional::signal bool  broadcast  ) 
 

Signal a conditional object and a waiting threads.

Parameters:
broadcast this signal to all waiting threads if true.

bool Conditional::wait timeout_t  timer = 0,
bool  locked = false
 

Wait to be signaled from another thread.

Parameters:
time period to wait.
flag if already locked the mutex.


The documentation for this class was generated from the following file:
Generated on Fri Feb 27 11:37:10 2004 for GNU CommonC++ by doxygen 1.3.5