#include <CountingSemaphore.h>

Public Member Functions | |
CountingSemaphore (int initialCount=0) | |
virtual | ~CountingSemaphore () |
Destroy the CountingSemaphore. | |
void | wait () |
bool | tryWait (unsigned long timeout) |
void | post () |
virtual int | count () |
virtual bool | tryAcquire (unsigned long timeout) |
virtual void | acquire () |
virtual void | release () |
![]() | |
virtual | ~Lockable () |
Destroy a Lockable object. | |
virtual void | acquire ()=0 |
virtual bool | tryAcquire (unsigned long timeout)=0 |
virtual void | release ()=0 |
Detailed Description
- Date
- <2003-07-16T15:26:18-0400>
- Version
- 2.2.1
A CountingSemaphore is an owner-less Lockable object.
It differs from a normal Semaphore in that there is no upper bound on the count and it will not throw an exception because a maximum value has been exceeded.
- See also
- Semaphore
Threads blocked on a CountingSemaphore are resumed in FIFO order.
Constructor & Destructor Documentation
◆ CountingSemaphore()
CountingSemaphore | ( | int | initialCount = 0 | ) |
Create a new CountingSemaphore.
- Parameters
-
count - initial count
Member Function Documentation
◆ acquire()
|
virtual |
Decrement the count, blocking that calling thread if the count becomes 0 or less than 0. The calling thread will remain blocked until the count is raised above 0 or if an exception is thrown.
- Exceptions
-
Interrupted_Exception thrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending any wait.
- See also
- Lockable::acquire()
Implements Lockable.
◆ count()
|
virtual |
Get the current count of the semaphore.
This value may change immediately after this function returns to the calling thread.
- Returns
- int count
◆ post()
◆ release()
|
virtual |
Increment the count, unblocking one thread if count is positive.
- See also
- Lockable::release()
Implements Lockable.
◆ tryAcquire()
|
virtual |
Decrement the count, blocking that calling thread if the count becomes 0 or less than 0. The calling thread will remain blocked until the count is raised above 0, an exception is thrown or the given amount of time expires.
- Parameters
-
timeout maximum amount of time (milliseconds) this method could block
- Returns
- true if the Semaphore was acquired before timeout milliseconds elapse.
- false otherwise.
- Exceptions
-
Interrupted_Exception thrown when the calling thread is interrupted. A thread may be interrupted at any time, prematurely ending any wait.
Implements Lockable.
◆ tryWait()
bool tryWait | ( | unsigned long | timeout | ) |
Provided to reflect the traditional Semaphore semantics
◆ wait()
The documentation for this class was generated from the following file:
- CountingSemaphore.h