#include <Thread.h>
Public Member Functions | |
Semaphore () | |
Class constructor. | |
virtual | ~Semaphore () |
Class destructor. | |
void | post () |
Post semaphore. | |
bool | pend () |
Pend on semaphore. | |
bool | pend (int ms) |
Pend on semaphore with timeout. |
Semaphore class.
Implements a semaphore based on pthread mutex and conditional.
Semaphore::Semaphore | ( | ) |
Class constructor.
Initializes the semaphore object. Initial state of the semaphore is not posted.
Semaphore::~Semaphore | ( | ) | [virtual] |
Class destructor.
Terminates the semaphore object. The semaphore is not posted before termination.
bool Semaphore::pend | ( | int | ms | ) |
Pend on semaphore with timeout.
Pends on the semaphore (or waits, acquires the semaphore) for the given amount of time. The call will block until another thread posts the semaphore, or the timeout expires.
ms | Pending operation timeout, in milliseconds. |
bool Semaphore::pend | ( | ) |
Pend on semaphore.
Pends on the semaphore (or waits, acquires the semaphore). The call will block until another thread posts the semaphore.
void Semaphore::post | ( | ) |
Post semaphore.
Posts (or signals, releases) a semaphore. The first thread pending on the semaphore will be released.