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 | |
binary_semaphore () | |
~binary_semaphore () | |
void | signal () |
Signals a semaphore. More... | |
void | wait () |
Waits a semaphore. More... | |
bool | try_wait (std::chrono::milliseconds ms=std::chrono::milliseconds(0)) |
Tries to wait on semaphore without lock. More... | |
binary_semaphore (const binary_semaphore &)=delete | |
binary_semaphore & | operator= (const binary_semaphore &)=delete |
constexpr | binary_semaphore () |
Constructs semaphore. More... | |
void | signal () |
Signals semaphore, sets counter to 1. More... | |
void | wait () |
Waits for semaphore, sets counter to 0. More... | |
bool | try_wait (std::chrono::milliseconds ms=std::chrono::milliseconds(0)) |
Tries to wait for semaphore signal. More... | |
binary_semaphore (const binary_semaphore &)=delete | |
binary_semaphore & | operator= (const binary_semaphore &)=delete |
binary_semaphore () | |
Constructs semaphore. More... | |
void | signal () |
Signals semaphore, sets counter to 1. More... | |
void | wait () |
Waits for semaphore, sets counter to 0. More... | |
bool | try_wait (std::chrono::milliseconds ms=std::chrono::milliseconds(0)) |
Tries to wait for semaphore signal. More... | |
binary_semaphore (const binary_semaphore &)=delete | |
binary_semaphore & | operator= (const binary_semaphore &)=delete |
FreeRTOS-based semaphore.
Binary semaphore.
Naive binary semaphore, acting like spinlock of some kind.
This semaphore is specific. It can only be raisen or cleared. Default state is cleared, so calling wait() would block until someone will call signal()
Suitable for targets without OS included and without WFI/WFE enabled. Useful during bring-up of new platforms. Main requirement - atomic support. Can take only two values - 0 or 1.
Can take only two values - 0 or 1.
ecl::binary_semaphore::binary_semaphore | ( | ) |
ecl::binary_semaphore::~binary_semaphore | ( | ) |
|
delete |
|
inline |
Constructs semaphore.
|
delete |
ecl::binary_semaphore::binary_semaphore | ( | ) |
Constructs semaphore.
|
delete |
void ecl::binary_semaphore::signal | ( | ) |
Signals a semaphore.
Can be called from ISR
void ecl::binary_semaphore::wait | ( | ) |
bool ecl::binary_semaphore::try_wait | ( | std::chrono::milliseconds | ms = std::chrono::milliseconds(0) | ) |
Tries to wait on semaphore without lock.
[in] | ms | Milliseconds to wait. |
false | Someone already waits a semaphore. |
true | Semaphore counter decremented. |
|
delete |
void ecl::binary_semaphore::signal | ( | ) |
Signals semaphore, sets counter to 1.
Can be called from ISR.
void ecl::binary_semaphore::wait | ( | ) |
Waits for semaphore, sets counter to 0.
bool ecl::binary_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. |
|
delete |
void ecl::binary_semaphore::signal | ( | ) |
Signals semaphore, sets counter to 1.
Can be called from ISR.
void ecl::binary_semaphore::wait | ( | ) |
Waits for semaphore, sets counter to 0.
bool ecl::binary_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. |
|
delete |