Orocos Real-Time Toolkit
2.5.0
|
An object oriented wrapper around a counting semaphore. More...
#include <rtt/os/Semaphore.hpp>
Public Member Functions | |
Semaphore (int count) | |
Initialize a Semaphore with an initial count. | |
~Semaphore () | |
Destroy a Semaphore. | |
void | wait () |
Lower this semaphore and return if value() is non zero. | |
void | signal () |
Raise this semaphore and signal one thread waiting on this semaphore. | |
bool | trywait () |
Try to wait on this semaphore. | |
bool | waitUntil (Seconds abs_time) |
Wait on this semaphore until a maximum absolute time. | |
bool | waitUntil (nsecs abs_time) |
Wait on this semaphore until a maximum absolute time. | |
int | value () |
Return the current count of this semaphore. |
An object oriented wrapper around a counting semaphore.
It works like a traffic light on which a thread can wait() until the sempahore's value becomes positive, otherwise it blocks. Another thread then needs to signal() the semaphore. One thread which is waiting will then be awakened, if none is waiting, the first thread calling wait() will continue directly (and decrease the value by 1).
Definition at line 61 of file Semaphore.hpp.
RTT::os::Semaphore::Semaphore | ( | int | count | ) | [inline] |
Initialize a Semaphore with an initial count.
Definition at line 70 of file Semaphore.hpp.
References rtos_sem_init().
bool RTT::os::Semaphore::trywait | ( | ) | [inline] |
Try to wait on this semaphore.
Definition at line 106 of file Semaphore.hpp.
void RTT::os::Semaphore::wait | ( | ) | [inline] |
Lower this semaphore and return if value() is non zero.
Or wait if value() is zero until a signal occurs.
Definition at line 87 of file Semaphore.hpp.
bool RTT::os::Semaphore::waitUntil | ( | Seconds | abs_time | ) | [inline] |
Wait on this semaphore until a maximum absolute time.
abs_time | Absolute time in seconds until which to wait on this semaphore. |
true | if the semaphore was signaled before abs_time expired. |
false | if the semaphore was not signaled. |
Definition at line 120 of file Semaphore.hpp.
bool RTT::os::Semaphore::waitUntil | ( | nsecs | abs_time | ) | [inline] |
Wait on this semaphore until a maximum absolute time.
abs_time | Absolute time in nano seconds until which to wait on this semaphore. |
true | if the semaphore was signaled before abs_time expired. |
false | if the semaphore was not signaled. |
Definition at line 134 of file Semaphore.hpp.