WPILibC++ 2023.4.3-108-ge5452e3
|
A semaphore for synchronization. More...
#include <wpi/Synchronization.h>
Public Member Functions | |
Semaphore (int initialCount=0, int maximumCount=INT_MAX) | |
Constructor. More... | |
~Semaphore () | |
Semaphore (const Semaphore &)=delete | |
Semaphore & | operator= (const Semaphore &)=delete |
Semaphore (Semaphore &&rhs) | |
Semaphore & | operator= (Semaphore &&rhs) |
operator WPI_Handle () const | |
Gets the semaphore handle (e.g. More... | |
WPI_SemaphoreHandle | GetHandle () const |
Gets the semaphore handle (e.g. More... | |
bool | Release (int releaseCount=1, int *prevCount=nullptr) |
Releases N counts of the semaphore. More... | |
A semaphore for synchronization.
Semaphores keep an internal counter. Releasing the semaphore increases the count. A semaphore with a non-zero count is considered signaled. When a waiter wakes up it atomically decrements the count by 1. This is generally useful in a single-supplier, multiple-consumer scenario.
|
inlineexplicit |
Constructor.
initialCount | initial value for the semaphore's internal counter |
maximumCount | maximum value for the samephore's internal counter |
|
inline |
|
delete |
|
inline |
|
inline |
Gets the semaphore handle (e.g.
for WaitForObject).
|
inlineexplicit |
Gets the semaphore handle (e.g.
for WaitForObject).
|
inline |
Releases N counts of the semaphore.
releaseCount | amount to add to semaphore's internal counter; must be positive |
prevCount | if non-null, previous count (output parameter) |