Flutter Engine
The Flutter Engine
|
A traditional counting semaphore. Wait
s 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. More... | |
~Semaphore () | |
Destroy the counting semaphore. More... | |
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 Wait s on invalid semaphore handles will fail and Signal calls will be ignored. More... | |
bool | Wait () |
Decrements the count and waits indefinitely if the value is less than zero for a Signal . More... | |
bool | TryWait () |
Decrement the counts if it is greater than zero. Returns false if the counter is already at zero. More... | |
void | Signal () |
Increment the count by one. Any pending Wait s will be resolved at this point. More... | |
A traditional counting semaphore. Wait
s 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 26 of file semaphore.h.
|
explicit |
Initializes the counting semaphore to a specified start count.
IsValid
method. Wait
s 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 Wait
s on invalid semaphore handles will fail and Signal
calls will be ignored.
Definition at line 177 of file semaphore.cc.
void fml::Semaphore::Signal | ( | ) |
Increment the count by one. Any pending Wait
s will be resolved at this point.
Definition at line 189 of file semaphore.cc.
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.
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.