ITK  4.13.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
itk::ConditionVariable Class Reference

#include <itkConditionVariable.h>

+ Inheritance diagram for itk::ConditionVariable:
+ Collaboration diagram for itk::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 58 of file itkConditionVariable.h.

Public Types

typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef ConditionVariable Self
 
typedef LightObject Superclass
 
- Public Types inherited from itk::LightObject
typedef SmartPointer< const SelfConstPointer
 
typedef SmartPointer< SelfPointer
 
typedef LightObject Self
 

Public Member Functions

void Broadcast ()
 
virtual ::itk::LightObject::Pointer CreateAnother () const
 
virtual const char * GetNameOfClass () const
 
void Signal ()
 
void Wait (SimpleMutexLock *mutex)
 
- Public Member Functions inherited from itk::LightObject
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
 itkCloneMacro (Self)
 
void Print (std::ostream &os, Indent indent=0) const
 
virtual void Register () const
 
virtual void SetReferenceCount (int)
 
virtual void UnRegister () const noexcept
 

Static Public Member Functions

static Pointer New ()
 
- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

 ConditionVariable ()
 
 ~ConditionVariable () override
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintSelf (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Private Member Functions

 ConditionVariable (const Self &other)
 
const Selfoperator= (const Self &)
 

Private Attributes

ConditionVariableType m_ConditionVariable
 

Additional Inherited Members

- Protected Attributes inherited from itk::LightObject
AtomicInt< int > m_ReferenceCount
 

Member Typedef Documentation

Definition at line 65 of file itkConditionVariable.h.

Definition at line 64 of file itkConditionVariable.h.

Standard class typedefs.

Definition at line 62 of file itkConditionVariable.h.

Definition at line 63 of file itkConditionVariable.h.

Constructor & Destructor Documentation

itk::ConditionVariable::ConditionVariable ( )
protected
itk::ConditionVariable::~ConditionVariable ( )
overrideprotected
itk::ConditionVariable::ConditionVariable ( const Self other)
private

Member Function Documentation

void itk::ConditionVariable::Broadcast ( )

Signal that the condition is true and release all waiting threads

virtual::itk::LightObject::Pointer itk::ConditionVariable::CreateAnother ( ) const
virtual

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Reimplemented from itk::LightObject.

virtual const char* itk::ConditionVariable::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods).

Reimplemented from itk::LightObject.

static Pointer itk::ConditionVariable::New ( )
static

Method for creation through the object factory.

const Self& itk::ConditionVariable::operator= ( const Self )
private
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.

Member Data Documentation

ConditionVariableType itk::ConditionVariable::m_ConditionVariable
private

Definition at line 92 of file itkConditionVariable.h.


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