FreeRTOS C++ Wrappers  1.6.0
C++ interface to FreeRTOS
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:
Inheritance graph
[legend]

Public Member Functions

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

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.

Definition at line 119 of file semaphore.hpp.

Constructor & Destructor Documentation

◆ ~Semaphore()

Semaphore::~Semaphore ( )
virtual

Our destructor

Definition at line 91 of file csemaphore.cpp.

◆ Semaphore()

Semaphore::Semaphore ( )
protected

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

Definition at line 86 of file csemaphore.cpp.

Member Function Documentation

◆ Give()

bool Semaphore::Give ( )

Release (give) a semaphore.

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

Definition at line 66 of file csemaphore.cpp.

◆ 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.

Definition at line 76 of file csemaphore.cpp.

◆ 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.

Definition at line 46 of file csemaphore.cpp.

◆ 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.

Definition at line 56 of file csemaphore.cpp.

Member Data Documentation

◆ handle

SemaphoreHandle_t cpp_freertos::Semaphore::handle
protected

FreeRTOS semaphore handle.

Definition at line 181 of file semaphore.hpp.


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