ITK  4.2.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 Types inherited from itk::LightObject

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 ()
- 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

Static Public Member Functions

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

Protected Member Functions

std::string NeverUseThisCompilerWarningAvoidanceFunctionForPad1Pad2 (void) const
 Semaphore ()
 ~Semaphore ()
- 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 Attributes

char m_Pad1 [128]
char m_Pad2 [128]
SemaphoreType m_Sema

Additional Inherited Members

- Protected Types inherited from itk::LightObject
typedef int InternalReferenceCountType
- Protected Attributes inherited from itk::LightObject
InternalReferenceCountType m_ReferenceCount
SimpleFastMutexLock m_ReferenceCountLock

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.

void itk::Semaphore::Down ( )

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.

std::string itk::Semaphore::NeverUseThisCompilerWarningAvoidanceFunctionForPad1Pad2 ( void  ) const
inlineprotected

Definition at line 141 of file itkSemaphore.h.

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

Method for creation through the object factory.

Reimplemented from itk::LightObject.

void itk::Semaphore::Remove ( )

Remove the semaphore from the system.

void itk::Semaphore::Up ( )

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


Member Data Documentation

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

Definition at line 167 of file itkSemaphore.h.

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

Definition at line 172 of file itkSemaphore.h.

SemaphoreType itk::Semaphore::m_Sema
private

Definition at line 170 of file itkSemaphore.h.


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