Main Page Namespace List Class Hierarchy Compound List Compound Members

# ZThread::CountingSemaphore Class Reference

`#include <CountingSemaphore.h>`

Inheritance diagram for ZThread::CountingSemaphore::

List of all members.

## Public Methods
| CountingSemaphore (int initialCount=0) throw (Synchronization_Exception)
virtual | ~CountingSemaphore () throw ()
void | wait () throw (Synchronization_Exception)
bool | tryWait (unsigned long) throw (Synchronization_Exception)
void | post () throw (Synchronization_Exception)
virtual int | count () throw ()
virtual bool | tryAcquire (unsigned long) throw (Synchronization_Exception)
virtual void | acquire () throw (Synchronization_Exception)
virtual void | release () throw (Synchronization_Exception)

## Detailed Description

Author:
  Eric Crahen

Date:
  04-12-2001

Version:
  1.3.4

Very similar to the Semaphore object. The difference here is that there is no upper bound on this Semaphore and it will not throw exceptions because a range has been exceeded

See also:
  Semaphore

## Constructor & Destructor Documentation

CountingSemaphore ( | int initialCount = 0 ) throw (Synchronization_Exception)

  | Create a new semaphore of a given size with a given count Parameters:
  initialCount | initial count to assign this semaphore
  Parameters:
  initialCount |

~CountingSemaphore ( | ) throw ()`[virtual]`

| Destroy this Semaphore

## Member Function Documentation

void acquire ( | ) throw (Synchronization_Exception)`[virtual]`

  | Decrements the semaphore. If the count is 0 - block until its raised above 0. Exceptions:
  Interrupted_Exception | - thrown if the thread is interrupted while waiting for this semaphore, or if it was interrupted before the function was called
  Unexpected_Exception | - the calling thread was killed and can't be blocked
  Synchronization_Exception | - error with the underlying synchronization mechanisms
Reimplemented from ZThread::Lockable.

int count ( | ) throw ()`[virtual]`

| Current count of this Semaphore Returns: int - current count

void post ( | ) throw (Synchronization_Exception)

| This method will increment the semaphore count by one, if any threads were wait()ing on this semaphore - then one will be unblocked. An exception will not be thrown because a range has been exceeded

void release ( | ) throw (Synchronization_Exception)`[virtual]`

  | Increment the semaphore Exceptions:
  InvalidOp_Exception | - thrown if this would increase the count beyond the maximum
  Synchronization_Exception | - error with the underlying synchronization mechanisms
Reimplemented from ZThread::Lockable.

bool tryAcquire ( | unsigned long timeout ) throw (Synchronization_Exception)`[virtual]`

  | Decrements the semaphore. If the count is 0 - block until its raised above 0. Parameters:
  unsigned | long - amount of time to spend trying to acquire
  Returns: true - the semaphore was acquired in time, false if not Exceptions:
  Interrupted_Exception | - thrown if the thread is interrupted while waiting for this semaphore, or if it was interrupted before the function was called
  Unexpected_Exception | - the calling thread was killed and can't be blocked
  Synchronization_Exception | - error with the underlying synchronization mechanisms
  Parameters:
  timeout |
Reimplemented from ZThread::Lockable.

bool tryWait ( | unsigned long ) throw (Synchronization_Exception)

  | See also: tryAcquire() - provided to reflect the traditional Semaphore semantics Parameters:
  long |

void wait ( | ) throw (Synchronization_Exception)

| See also: acquire() - provided to reflect the traditional Semaphore semantics

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

- CountingSemaphore.h