Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
igtl::ConditionVariable Class Reference

#include <igtlConditionVariable.h>

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

Public Types

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

Public Member Functions

void Broadcast ()
 
virtual Pointer CreateAnother () const
 
virtual void Delete ()
 
virtual const char * GetNameOfClass () const
 
virtual int GetReferenceCount () const
 
 igtlNewMacro (Self)
 
 igtlTypeMacro (ConditionVariable, LightObject)
 
void Print (std::ostream &os) const
 
virtual void Register () const
 
virtual void SetReferenceCount (int)
 
void Signal ()
 
virtual void UnRegister () const
 
void Wait (SimpleMutexLock *mutex)
 

Static Public Member Functions

static void BreakOnError ()
 
static Pointer New ()
 

Protected Member Functions

 ConditionVariable ()
 
 ~ConditionVariable ()
 
virtual void PrintSelf (std::ostream &os) const
 
virtual void PrintHeader (std::ostream &os) const
 
virtual void PrintTrailer (std::ostream &os) const
 

Protected Attributes

volatile int m_ReferenceCount
 
SimpleFastMutexLock m_ReferenceCountLock
 

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 IGTL 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 82 of file igtlConditionVariable.h.

Member Typedef Documentation

Definition at line 89 of file igtlConditionVariable.h.

Definition at line 88 of file igtlConditionVariable.h.

Standard class typedefs.

Definition at line 86 of file igtlConditionVariable.h.

Definition at line 87 of file igtlConditionVariable.h.

Constructor & Destructor Documentation

igtl::ConditionVariable::ConditionVariable ( )
protected
igtl::ConditionVariable::~ConditionVariable ( )
protected

Member Function Documentation

static void igtl::LightObject::BreakOnError ( )
staticinherited

This method is called when igtlExceptionMacro executes. It allows the debugger to break on error.

void igtl::ConditionVariable::Broadcast ( )

Signal that the condition is true and release all waiting threads

virtual Pointer igtl::LightObject::CreateAnother ( ) const
virtualinherited

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 in igtl::Object.

virtual void igtl::LightObject::Delete ( )
virtualinherited

Delete an igtl object. This method should always be used to delete an object when the new operator was used to create it. Using the C delete method will not work with reference counting.

virtual const char* igtl::LightObject::GetNameOfClass ( ) const
inlinevirtualinherited

Return the name of this class as a string. Used by the object factory (implemented in New()) to instantiate objects of a named type. Also used for debugging and other output information.

Definition at line 84 of file igtlLightObject.h.

virtual int igtl::LightObject::GetReferenceCount ( ) const
inlinevirtualinherited

Gets the reference count on this object.

Definition at line 110 of file igtlLightObject.h.

igtl::ConditionVariable::igtlNewMacro ( Self  )

Method for creation through the object factory.

igtl::ConditionVariable::igtlTypeMacro ( ConditionVariable  ,
LightObject   
)

Run-time type information (and related methods).

static Pointer igtl::LightObject::New ( )
staticinherited

Method for creation through the object factory.

void igtl::LightObject::Print ( std::ostream &  os) const
inherited

Cause the object to print itself out.

virtual void igtl::LightObject::PrintHeader ( std::ostream &  os) const
protectedvirtualinherited

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

virtual void igtl::LightObject::PrintSelf ( std::ostream &  os) const
protectedvirtualinherited

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented in igtl::MultiThreader, igtl::Object, igtl::MutexLock, igtl::ObjectFactoryBase, igtl::Socket, igtl::FastMutexLock, igtl::TimeStamp, igtl::ServerSocket, and igtl::ClientSocket.

virtual void igtl::LightObject::PrintTrailer ( std::ostream &  os) const
protectedvirtualinherited

Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

virtual void igtl::LightObject::Register ( ) const
virtualinherited

Increase the reference count (mark as used by another object).

Reimplemented in igtl::Object.

virtual void igtl::LightObject::SetReferenceCount ( int  )
virtualinherited

Sets the reference count on this object. This is a dangerous method, use it with care.

Reimplemented in igtl::Object.

void igtl::ConditionVariable::Signal ( )

Signal that the condition is true and release one waiting thread

virtual void igtl::LightObject::UnRegister ( ) const
virtualinherited

Decrease the reference count (release by another object).

Reimplemented in igtl::Object.

void igtl::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

volatile int igtl::LightObject::m_ReferenceCount
mutableprotectedinherited

Number of uses of this object by other objects.

Definition at line 131 of file igtlLightObject.h.

SimpleFastMutexLock igtl::LightObject::m_ReferenceCountLock
mutableprotectedinherited

Mutex lock to protect modification to the reference count

Definition at line 134 of file igtlLightObject.h.


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

Generated at Wed Dec 4 2013 11:11:31 for OpenIGTLink by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2012