|
UtiLite
0.3.1
A lite utilities library
|
#include <USemaphore.h>
Public Member Functions | |
| USemaphore (int initValue=0) | |
| void | acquire (int n=1) |
| void | release (int n=1) |
| int | value () |
A semaphore class.
On an acquire() call, the calling thread is blocked if the USemaphore's value is <= 0. It is unblocked when release() is called. The function acquire() decreases by 1 (default) the semaphore's value and release() increases it by 1 (default).
Example:
USemaphore s; s.acquire(); // Will wait until s.release() is called by another thread.
| USemaphore::USemaphore | ( | int | initValue = 0 | ) | [inline] |
The constructor. The semaphore waits on acquire() when its value is <= 0.
| n | number to initialize |
| void USemaphore::acquire | ( | int | n = 1 | ) | [inline] |
Acquire the semaphore. If semaphore's value is <=0, the calling thread will wait until the count acquired is released.
| n | number to acquire |
| void USemaphore::release | ( | int | n = 1 | ) | [inline] |
Release the semaphore, increasing its value by 1 and signaling waiting threads (which called acquire()).
| int USemaphore::value | ( | ) | [inline] |
Get the USempahore's value.
1.7.6.1