ITK  4.1.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
itk::Semaphore Class Reference

#include <itkSemaphore.h>

+ Inheritance diagram for itk::Semaphore:
+ Collaboration diagram for itk::Semaphore:

List of all members.

Public Types

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

Public Member Functions

virtual ::itk::LightObject::Pointer CreateAnother (void) const
void Down ()
virtual const char * GetNameOfClass () const
void Initialize (unsigned int value)
void Remove ()
void Up ()

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 Semaphore ()
 ~Semaphore ()

Private Attributes

SemaphoreType m_Sema
char Pad1 [128]
char Pad2 [128]

Detailed Description

The semaphore class is used to synchronize execution between threads.

Semaphore objects maintain a counter value that can be incremented and decremented by atomic calls to Up() and Down(). Semaphores are commonly used to manage the use of a limited pool of system resources among several threads. If Down() is called when the value of the semaphore is zero, the calling thread will block until the semaphore value goes above zero again. When a blocked thread is released, it decrements the Semaphore counter before continuing to execute.

The Up() and Down() operations are standard as defined by E.W. Dijkstra. The Initialize( num ) operation creates the system semaphore object with an initial counter value of num. Initialize must be called before the Semaphore can be used. The Remove() method destroys the system semaphore object. It is not necessary to call Remove() unless you want to re-Initialize() the object.

This class supports 3 types of semaphores on Unix systems, POSIX semaphores, and IPC semaphores. On Windows systems, POSIX semaphores and WIN32 thread library semaphores are supported.

Definition at line 102 of file itkSemaphore.h.


Member Typedef Documentation

Reimplemented from itk::LightObject.

Definition at line 109 of file itkSemaphore.h.

Reimplemented from itk::LightObject.

Definition at line 108 of file itkSemaphore.h.

Standard class typedefs.

Reimplemented from itk::LightObject.

Definition at line 106 of file itkSemaphore.h.

Definition at line 107 of file itkSemaphore.h.


Constructor & Destructor Documentation

itk::Semaphore::Semaphore ( ) [protected]
itk::Semaphore::~Semaphore ( ) [protected]

Member Function Documentation

virtual::itk::LightObject::Pointer itk::Semaphore::CreateAnother ( void  ) 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.

Decrement the semaphore count. If the count is zero, this thread will be blocked until another thread calls the up() method. The order in which threads will be unblocked is not defined, but implementors should give preference to those threads that have waited the longest.

virtual const char* itk::Semaphore::GetNameOfClass ( ) const [virtual]

Run-time type information (and related methods).

Reimplemented from itk::LightObject.

void itk::Semaphore::Initialize ( unsigned int  value)

Initialize the semaphore with a count of value.

static Pointer itk::Semaphore::New ( ) [static]

Method for creation through the object factory.

Reimplemented from itk::LightObject.

Remove the semaphore from the system.

Increment the semaphore count, unblocking up to one thread that may be blocked in the down() method.


Member Data Documentation

Definition at line 161 of file itkSemaphore.h.

char itk::Semaphore::Pad1[128] [private]

Definition at line 159 of file itkSemaphore.h.

char itk::Semaphore::Pad2[128] [private]

Definition at line 162 of file itkSemaphore.h.


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