Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itk::ConditionVariable Class Reference

A thread synchronization object used to suspend execution until some condition on shared data is met. More...

#include <itkConditionVariable.h>

Inheritance diagram for itk::ConditionVariable:

Inheritance graph
[legend]
Collaboration diagram for itk::ConditionVariable:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ConditionVariable Self
typedef LightObject Superclass
typedef SmartPointer< SelfPointer
typedef SmartPointer< const
Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
void Wait (SimpleMutexLock *mutex)
void Signal ()
void Broadcast ()

Static Public Member Functions

Pointer New ()

Protected Member Functions

 ConditionVariable ()
 ~ConditionVariable ()

Detailed Description

A thread synchronization object used to suspend execution until some condition on shared data is met.

A thread calls Wait() to suspend its execution until the condition is met. Each call to Signal() from an executing thread will then cause a single waiting thread to be released. A call to Signal() means, "signal that the condition is true." Broadcast() releases all threads waiting on the condition variable.

The ITK ConditionVariable implementation is consistent with the standard definition and use of condition variables in pthreads and other common thread libraries.

IMPORTANT: A condition variable always requires an associated SimpleMutexLock object. The mutex object is used to avoid a dangerous race condition when Wait() and Signal() are called simultaneously from two different threads.

On systems using pthreads, this implementation abstract the standard calls to the pthread condition variable. On Win32 systems, there is no system provided condition variable. This class implements a condition variable using a critical section, a semphore, an event and a number of counters. The implementation is almost an extract translation of the implementation presented by Douglas C Schmidt and Irfan Pyarali in "Strategies for Implementing POSIX Condition Variables on Win32". This article can be found at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html

Definition at line 66 of file itkConditionVariable.h.


Member Typedef Documentation

typedef SmartPointer<const Self> itk::ConditionVariable::ConstPointer
 

Reimplemented from itk::LightObject.

Definition at line 73 of file itkConditionVariable.h.

typedef SmartPointer<Self> itk::ConditionVariable::Pointer
 

Reimplemented from itk::LightObject.

Definition at line 72 of file itkConditionVariable.h.

typedef ConditionVariable itk::ConditionVariable::Self
 

Standard class typedefs.

Reimplemented from itk::LightObject.

Definition at line 70 of file itkConditionVariable.h.

typedef LightObject itk::ConditionVariable::Superclass
 

Definition at line 71 of file itkConditionVariable.h.


Constructor & Destructor Documentation

itk::ConditionVariable::ConditionVariable  )  [protected]
 

itk::ConditionVariable::~ConditionVariable  )  [protected]
 


Member Function Documentation

void itk::ConditionVariable::Broadcast  ) 
 

Signal that the condition is true and release all waiting threads

virtual const char* itk::ConditionVariable::GetClassName  )  const [virtual]
 

Run-time type information (and related methods).

Pointer itk::ConditionVariable::New  )  [static]
 

Method for creation through the object factory.

Reimplemented from itk::LightObject.

void itk::ConditionVariable::Signal  ) 
 

Signal that the condition is true and release one waiting thread

void itk::ConditionVariable::Wait SimpleMutexLock mutex  ) 
 

Suspend execution of this thread until the condition is signaled. The argument is a SimpleMutex object that must be locked prior to calling this method.


The documentation for this class was generated from the following file:
Generated at Sun Apr 1 02:59:43 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000