![]() |
WPILibC++ 2025.3.2
|
A semaphore for synchronization. More...
#include <wpi/Synchronization.h>
Public Member Functions | |
| Semaphore (int initialCount=0, int maximumCount=INT_MAX) | |
| Constructor. | |
| ~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. | |
| WPI_SemaphoreHandle | GetHandle () const |
| Gets the semaphore handle (e.g. | |
| bool | Release (int releaseCount=1, int *prevCount=nullptr) |
| Releases N counts of the semaphore. | |
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 semaphore'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) |