theCore C++ embedded framework
ecl::semaphore Class Reference

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
 
semaphoreoperator= (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
 
semaphoreoperator= (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
 
semaphoreoperator= (const semaphore &)=delete
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ semaphore() [1/6]

ecl::semaphore::semaphore ( )

◆ ~semaphore()

ecl::semaphore::~semaphore ( )

◆ semaphore() [2/6]

ecl::semaphore::semaphore ( const semaphore )
delete

◆ semaphore() [3/6]

constexpr ecl::semaphore::semaphore ( )
inline

Constructs semaphore.

◆ semaphore() [4/6]

ecl::semaphore::semaphore ( const semaphore )
delete

◆ semaphore() [5/6]

ecl::semaphore::semaphore ( )

Constructs semaphore.

◆ semaphore() [6/6]

ecl::semaphore::semaphore ( const semaphore )
delete

Member Function Documentation

◆ signal() [1/3]

void ecl::semaphore::signal ( )

Signals a semaphore.

Can be called from ISR.

◆ wait() [1/3]

void ecl::semaphore::wait ( )

Waits a semaphore Cannot be called from ISR.

◆ try_wait() [1/3]

bool ecl::semaphore::try_wait ( std::chrono::milliseconds  ms = std::chrono::milliseconds(0))

Tries to wait on semaphore without lock.

Return values
falseWait will result in lock.
trueSemaphore counter decremented.

◆ operator=() [1/3]

semaphore& ecl::semaphore::operator= ( const semaphore )
delete

◆ signal() [2/3]

void ecl::semaphore::signal ( )

Signals semaphore, rises counter.

Can be called from ISR.

◆ wait() [2/3]

void ecl::semaphore::wait ( )

Waits for semaphore, decreases counter.

Not callable from ISR. Blocks until signal() is called in different context.

◆ try_wait() [2/3]

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.

Parameters
[in]msMilliseconds to wait.
Return values
trueSemaphore signal consumed, counter decreased.
falseNothing to consume.

◆ operator=() [2/3]

semaphore& ecl::semaphore::operator= ( const semaphore )
delete

◆ signal() [3/3]

void ecl::semaphore::signal ( )

Signals semaphore, rises counter.

◆ wait() [3/3]

void ecl::semaphore::wait ( )

Waits for semaphore, decreases counter.

Not callable from ISR. Blocks utill signal() is called in different context.

◆ try_wait() [3/3]

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.

Parameters
[in]msMilliseconds to wait.
Return values
trueSemaphore signal consumed, counter decreased.
falseNothing to consume.

◆ operator=() [3/3]

semaphore& ecl::semaphore::operator= ( const semaphore )
delete

The documentation for this class was generated from the following files: