theCore C++ embedded framework
|
FreeRTOS-based semaphore. More...
#include </home/travis/build/forGGe/theCore/lib/thread/posix/export/ecl/thread/semaphore.hpp>
Public Member Functions | |
semaphore () | |
~semaphore () | |
void | signal () |
Signals a semaphore. More... | |
void | wait () |
Waits a semaphore Cannot be called from ISR. More... | |
bool | try_wait (std::chrono::milliseconds ms=std::chrono::milliseconds(0)) |
Tries to wait on semaphore without lock. More... | |
semaphore (const semaphore &)=delete | |
semaphore & | operator= (const semaphore &)=delete |
constexpr | semaphore () |
Constructs semaphore. More... | |
void | signal () |
Signals semaphore, rises counter. More... | |
void | wait () |
Waits for semaphore, decreases counter. More... | |
bool | try_wait (std::chrono::milliseconds ms=std::chrono::milliseconds(0)) |
Tries to wait for semaphore signal. More... | |
semaphore (const semaphore &)=delete | |
semaphore & | operator= (const semaphore &)=delete |
semaphore () | |
Constructs semaphore. More... | |
void | signal () |
Signals semaphore, rises counter. More... | |
void | wait () |
Waits for semaphore, decreases counter. More... | |
bool | try_wait (std::chrono::milliseconds ms=std::chrono::milliseconds(0)) |
Tries to wait for semaphore signal. More... | |
semaphore (const semaphore &)=delete | |
semaphore & | operator= (const semaphore &)=delete |
FreeRTOS-based semaphore.
Counting semaphore.
Naive counting semaphore, acting like spinlock of some kind.
Suitable for targets without OS included and without WFI/WFE enabled. Useful during bring-up of new platforms. Main requirement - atomic support.
Implemented for host platform.
ecl::semaphore::semaphore | ( | ) |
ecl::semaphore::~semaphore | ( | ) |
|
delete |
|
inline |
Constructs semaphore.
|
delete |
ecl::semaphore::semaphore | ( | ) |
Constructs semaphore.
|
delete |
void ecl::semaphore::signal | ( | ) |
Signals a semaphore.
Can be called from ISR.
void ecl::semaphore::wait | ( | ) |
Waits a semaphore Cannot be called from ISR.
bool ecl::semaphore::try_wait | ( | std::chrono::milliseconds | ms = std::chrono::milliseconds(0) | ) |
Tries to wait on semaphore without lock.
false | Wait will result in lock. |
true | Semaphore counter decremented. |
void ecl::semaphore::signal | ( | ) |
Signals semaphore, rises counter.
Can be called from ISR.
void ecl::semaphore::wait | ( | ) |
Waits for semaphore, decreases counter.
Not callable from ISR. Blocks until signal() is called in different context.
bool ecl::semaphore::try_wait | ( | std::chrono::milliseconds | ms = std::chrono::milliseconds(0) | ) |
Tries to wait for semaphore signal.
Will wait for semaphore signal with provided timeout. If no parameter given then it will immediately exit if there is no pending signals.
[in] | ms | Milliseconds to wait. |
true | Semaphore signal consumed, counter decreased. |
false | Nothing to consume. |
void ecl::semaphore::signal | ( | ) |
Signals semaphore, rises counter.
void ecl::semaphore::wait | ( | ) |
Waits for semaphore, decreases counter.
Not callable from ISR. Blocks utill signal() is called in different context.
bool ecl::semaphore::try_wait | ( | std::chrono::milliseconds | ms = std::chrono::milliseconds(0) | ) |
Tries to wait for semaphore signal.
Will wait for semaphore signal with provided timeout. If no parameter given then it will immediatelly exit if there is no pending signals.
[in] | ms | Milliseconds to wait. |
true | Semaphore signal consumed, counter decreased. |
false | Nothing to consume. |