Panda3D
|
A classic semaphore synchronization primitive. More...
#include "psemaphore.h"
Public Member Functions | |
Semaphore (const Semaphore ©)=delete | |
Semaphore (int initial_count=1) | |
void | acquire () |
Decrements the internal count. | |
int | get_count () const |
Returns the current semaphore count. | |
Semaphore & | operator= (const Semaphore ©)=delete |
void | output (std::ostream &out) const |
int | release () |
Increments the semaphore's internal count. | |
bool | try_acquire () |
If the semaphore can be acquired without blocking, does so and returns true. | |
A classic semaphore synchronization primitive.
A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release().
Definition at line 30 of file psemaphore.h.
|
inlineexplicit |
Definition at line 17 of file psemaphore.I.
|
inline |
Decrements the internal count.
If the count was already at zero, blocks until the count is nonzero, then decrements it.
Definition at line 30 of file psemaphore.I.
References ConditionVarDirect::wait().
|
inline |
Returns the current semaphore count.
Note that this call is not thread- safe (the count may change at any time).
Definition at line 76 of file psemaphore.I.
void Semaphore::output | ( | std::ostream & | out | ) | const |
Definition at line 19 of file psemaphore.cxx.
|
inline |
Increments the semaphore's internal count.
This may wake up another thread blocked on acquire().
Returns the count of the semaphore upon release.
Definition at line 63 of file psemaphore.I.
References ConditionVarDirect::notify().
|
inline |
If the semaphore can be acquired without blocking, does so and returns true.
Otherwise, returns false.
Definition at line 45 of file psemaphore.I.