A traditional counting semaphore. Waits decrement the counter and Signal increments it.
More...
#include <semaphore.h>
Public Member Functions | |
| Semaphore (uint32_t count) | |
| Initializes the counting semaphore to a specified start count. | |
| ~Semaphore () | |
| Destroy the counting semaphore. | |
| bool | IsValid () const |
Check if the underlying semaphore handle could be created. Failure modes are platform specific and may occur due to issue like handle exhaustion. All Waits on invalid semaphore handles will fail and Signal calls will be ignored. | |
| bool | Wait () |
Decrements the count and waits indefinitely if the value is less than zero for a Signal. | |
| bool | TryWait () |
| Decrement the counts if it is greater than zero. Returns false if the counter is already at zero. | |
| void | Signal () |
Increment the count by one. Any pending Waits will be resolved at this point. | |
A traditional counting semaphore. Waits decrement the counter and Signal increments it.
This is a cross-platform replacement for std::counting_semaphore which is only available since C++20. Once Flutter migrates past that point, this class should become obsolete and must be replaced.
Definition at line 25 of file semaphore.h.
|
explicit |
Initializes the counting semaphore to a specified start count.
IsValid method. Waits on an invalid semaphore will always fail and signals will fail silently.| [in] | count | The starting count of the counting semaphore. |
Definition at line 173 of file semaphore.cc.
|
default |
Destroy the counting semaphore.
| bool fml::Semaphore::IsValid | ( | ) | const |
Check if the underlying semaphore handle could be created. Failure modes are platform specific and may occur due to issue like handle exhaustion. All Waits on invalid semaphore handles will fail and Signal calls will be ignored.
Definition at line 177 of file semaphore.cc.
Referenced by flutter::Pipeline< R >::IsValid(), TEST(), and TEST().
| void fml::Semaphore::Signal | ( | ) |
Increment the count by one. Any pending Waits will be resolved at this point.
Definition at line 189 of file semaphore.cc.
Referenced by flutter::Pipeline< R >::Consume(), TEST(), and TEST().
| bool fml::Semaphore::TryWait | ( | ) |
Decrement the counts if it is greater than zero. Returns false if the counter is already at zero.
Definition at line 185 of file semaphore.cc.
Referenced by flutter::Pipeline< R >::Consume(), flutter::Pipeline< R >::Produce(), flutter::Pipeline< R >::ProduceIfEmpty(), TEST(), and TEST().
| bool fml::Semaphore::Wait | ( | ) |
Decrements the count and waits indefinitely if the value is less than zero for a Signal.
Wait call was successful. See IsValid for failure. Definition at line 181 of file semaphore.cc.
Referenced by TEST().