ardour
|
#include <semaphore.h>
Public Member Functions | |
Semaphore (unsigned initial) | |
~Semaphore () | |
void | post () |
bool | wait () |
bool | try_wait () |
Private Attributes | |
sem_t | _sem |
Unnamed (process local) counting semaphore.
The civilized person's synchronisation primitive. A counting semaphore is an integer which is always non-negative, so, an attempted decrement (or "wait") will block if the value is 0, until another thread does an increment (or "post").
At least on Lignux, the main advantage of this is that it is fast and the only safe way to reliably signal from a real-time audio thread. The counting semantics also complement ringbuffers of events nicely.
Definition at line 52 of file semaphore.h.
|
inline |
Create a new semaphore.
Chances are you want 1 wait() per 1 post(), an initial value of 0.
Definition at line 160 of file semaphore.h.
|
inline |
Definition at line 168 of file semaphore.h.
|
inline |
Post/Increment/Signal
Definition at line 174 of file semaphore.h.
|
inline |
Attempt Wait/Decrement. Returns true iff a decrement occurred.
Definition at line 193 of file semaphore.h.
|
inline |
Wait/Decrement. Returns false on error.
Definition at line 180 of file semaphore.h.
|
private |
Definition at line 79 of file semaphore.h.