Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Phx::Semaphore Class Reference

A Semaphore class that wraps POSIX semaphores. More...

#include <PhxSemaphore.h>

List of all members.

Public Member Functions

 Semaphore (uint32_t initialValue=0)
 Constructs a semaphore, optionally with a non-zero initial value.
void signal (void)
 Atomically increments the semaphore value.
void wait (void)
 Waits until the semaphore takes on a non-zero value and then decrements it.
int value (void)


Detailed Description

A Semaphore class that wraps POSIX semaphores.

A semaphore represents an unsigned integral value that may be incremented and decremented atomically. When the value reaches zero, any attempts to decrement the semaphore (by calling wait()) will result in the caller block. If the value is non-zero then it will be decremented and the caller may continue. The semaphore value is incremented by calling signal().


Constructor & Destructor Documentation

Phx::Semaphore::Semaphore uint32_t  initialValue = 0  ) 
 

Constructs a semaphore, optionally with a non-zero initial value.

Parameters:
initialValue The initial count at which the semaphore will begin. This is the number of times that wait() can be called before further calls will block, in the absence of additional calls to signal().


Member Function Documentation

void Phx::Semaphore::signal void   ) 
 

Atomically increments the semaphore value.

If that value was zero, this potentially causes a caller waiting concurrently in a call to wait() to unblock (and subsequently decrement the semaphore again).

void Phx::Semaphore::wait void   ) 
 

Waits until the semaphore takes on a non-zero value and then decrements it.

If the semaphore value is zero then the caller will be blocked. After a call to signal() gives the semaphore a non-zero value, one caller will unblock and decrement the count before returning. Any additional callers will have to wait for additional calls to signal() to allow them to return.


The documentation for this class was generated from the following file:
Generated on Mon Jul 10 19:45:30 2006 for Phoenix OSFS by  doxygen 1.4.2