#include <itkSemaphore.h>
Inheritance diagram for itk::Semaphore:
Public Types | |
typedef Semaphore | Self |
typedef LightObject | Superclass |
typedef SmartPointer< Self > | Pointer |
typedef SmartPointer< const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
void | Initialize (unsigned int value) |
void | Up () |
void | Down () |
void | Remove () |
Static Public Member Functions | |
Pointer | New () |
Protected Member Functions | |
Semaphore () | |
~Semaphore () |
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, IPC semaphores, and IRIX semaphores from the SGI Sproc library. On Windows systems, POSIX semaphores and WIN32 thread library semaphores are supported.
Definition at line 112 of file itkSemaphore.h.
|
Reimplemented from itk::LightObject. Definition at line 119 of file itkSemaphore.h. |
|
Reimplemented from itk::LightObject. Definition at line 118 of file itkSemaphore.h. |
|
Standard class typedefs. Reimplemented from itk::LightObject. Definition at line 116 of file itkSemaphore.h. |
|
Definition at line 117 of file itkSemaphore.h. |
|
|
|
|
|
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. |
|
Run-time type information (and related methods). |
|
Initialize the semaphore with a count of value. |
|
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. |