#include <thread.h>
Public Member Functions | |
unsigned | getCount (void) |
Get active semaphore limit. | |
unsigned | getUsed (void) |
Get current semaphore usage. | |
void | operator++ (void) |
Convenience operator to wait on a counting semaphore. | |
void | operator-- (void) |
Convenience operator to release a counting semaphore. | |
void | release (void) |
Release the semaphore after waiting for it. | |
semaphore (unsigned count=0) | |
Construct a semaphore with an initial count of threads to permit. | |
void | set (unsigned count) |
Alter semaphore limit at runtime. | |
bool | wait (timeout_t timeout) |
Wait until the semphore usage count is less than the thread limit. | |
void | wait (void) |
Wait until the semphore usage count is less than the thread limit. | |
Static Public Member Functions | |
static void | release (semaphore &sync) |
Convenience class to release a semaphore. | |
static bool | wait (semaphore &sync, timeout_t timeout) |
Convenience class to wait on a semaphore. | |
static void | wait (semaphore &sync) |
Convenience class to wait on a semaphore. |
A semaphore will allow threads to pass through it until the count is reached, and blocks further threads. Unlike pthread semaphore, our semaphore class supports it's count limit to be altered during runtime and the use of timed waits. This class also implements the shared_lock protocol.
Definition at line 1019 of file thread.h.
unsigned ucc::semaphore::getCount | ( | void | ) |
unsigned ucc::semaphore::getUsed | ( | void | ) |
static void ucc::semaphore::release | ( | semaphore & | sync | ) | [inline, static] |
void ucc::semaphore::set | ( | unsigned | count | ) |
static void ucc::semaphore::wait | ( | semaphore & | sync | ) | [inline, static] |
bool ucc::semaphore::wait | ( | timeout_t | timeout | ) |
Wait until the semphore usage count is less than the thread limit.
Increase used count for our thread when unblocked, or return without changing if timed out.
timeout | to wait in millseconds. |
Reimplemented from ucc::Conditional.
void ucc::semaphore::wait | ( | void | ) |
Wait until the semphore usage count is less than the thread limit.
Increase used count for our thread when unblocked.
Reimplemented from ucc::Conditional.