FreeRTOS Addons
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cpp_freertos::Semaphore Class Reference

#include <semaphore.hpp>

Inheritance diagram for cpp_freertos::Semaphore:
cpp_freertos::BinarySemaphore cpp_freertos::CountingSemaphore

Public Member Functions

virtual ~Semaphore ()
 
bool Give ()
 
bool GiveFromISR (BaseType_t *pxHigherPriorityTaskWoken)
 
bool Take (TickType_t Timeout=portMAX_DELAY)
 
bool TakeFromISR (BaseType_t *pxHigherPriorityTaskWoken)
 

Protected Member Functions

 Semaphore ()
 

Protected Attributes

SemaphoreHandle_t handle
 

Detailed Description

Base wrapper class around FreeRTOS's implementation of semaphores.

It is not expected that an application will derive from this class.

Note that we distinguish between Semaphore, Binary Semaphores, Counting Semaphores, and Mutexes. Mutexes, while implemented as a kind of semaphore in FreeRTOS, are conceptually very different in use and behavior from semaphores. We acknowledge this difference in the class heirarchy, implementing mutextes as a completely different class heirarchy.

Constructor & Destructor Documentation

◆ ~Semaphore()

Semaphore::~Semaphore ( )
virtual

Our destructor

◆ Semaphore()

Semaphore::Semaphore ( )
protected

We do not want a Semaphore ctor. This class should never be directly created, this is a base class only.

Member Function Documentation

◆ Give()

bool Semaphore::Give ( )

Release (give) a semaphore.

Returns
true if the Semaphore was released, false if it failed.

◆ GiveFromISR()

bool Semaphore::GiveFromISR ( BaseType_t *  pxHigherPriorityTaskWoken)

Release (give) a semaphore from ISR context.

Parameters
pxHigherPriorityTaskWokenDid this operation result in a rescheduling event.
Returns
true if the Semaphore was released, false if it failed.

◆ Take()

bool Semaphore::Take ( TickType_t  Timeout = portMAX_DELAY)

Aquire (take) a semaphore.

Example of blocking indefinitely: aSemaphore.Take();

Example of blocking for 100 ticks: aSemaphore.Take(100);

Parameters
TimeoutHow long to wait to get the Lock until giving up.
Returns
true if the Semaphore was acquired, false if it timed out.

◆ TakeFromISR()

bool Semaphore::TakeFromISR ( BaseType_t *  pxHigherPriorityTaskWoken)

Aquire (take) a semaphore from ISR context.

Parameters
pxHigherPriorityTaskWokenDid this operation result in a rescheduling event.
Returns
true if the Semaphore was acquired, false if it timed out.

Member Data Documentation

◆ handle

SemaphoreHandle_t cpp_freertos::Semaphore::handle
protected

FreeRTOS semaphore handle.


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