FreeRTOS-Cpp
|
Class that encapsulates the functionality of a FreeRTOS counting semaphore. More...
#include <FreeRTOS/Semaphore.hpp>
Public Member Functions | |
CountingSemaphore (const UBaseType_t maxCount, const UBaseType_t initialCount=0) | |
Construct a new CountingSemaphore by calling SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount) More... | |
CountingSemaphore (const CountingSemaphore &)=delete | |
CountingSemaphore & | operator= (const CountingSemaphore &)=delete |
CountingSemaphore (CountingSemaphore &&) noexcept=default | |
CountingSemaphore & | operator= (CountingSemaphore &&) noexcept=default |
![]() | |
SemaphoreBase (const SemaphoreBase &)=delete | |
SemaphoreBase & | operator= (const SemaphoreBase &)=delete |
bool | isValid () const |
Function that checks if the underlying semaphore handle is not NULL. This should be used to ensure a semaphore has been created correctly. More... | |
UBaseType_t | getCount () const |
Function that calls UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore ) More... | |
bool | take (const TickType_t ticksToWait=portMAX_DELAY) const |
Function that calls xSemaphoreTake( SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait ) More... | |
bool | takeFromISR (bool &higherPriorityTaskWoken) const |
Function that calls xSemaphoreTakeFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken) More... | |
bool | takeFromISR () const |
Function that calls xSemaphoreTakeFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken) More... | |
bool | give () const |
Function that calls xSemaphoreGive( SemaphoreHandle_t xSemaphore ) More... | |
bool | giveFromISR (bool &higherPriorityTaskWoken) const |
Function that calls xSemaphoreGiveFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken ) More... | |
bool | giveFromISR () const |
Function that calls xSemaphoreGiveFromISR( SemaphoreHandle_t xSemaphore, signed BaseType_t *pxHigherPriorityTaskWoken ) More... | |
Additional Inherited Members | |
![]() | |
static void * | operator new (size_t, void *ptr) |
static void * | operator new[] (size_t, void *ptr) |
static void * | operator new (size_t)=delete |
static void * | operator new[] (size_t)=delete |
Class that encapsulates the functionality of a FreeRTOS counting semaphore.
Each counting semaphore require a small amount of RAM that is used to hold the semaphore's state. If a counting semaphore is created using FreeRTOS::CountingSemaphore then the required RAM is automatically allocated from the FreeRTOS heap. If a counting semaphore is created using FreeRTOS::StaticCountingSemaphore then the RAM is provided by the application writer as part of the class and allows the RAM to be statically allocated at compile time. See the Static Vs Dynamic allocation page for more information.
Counting semaphores are typically used for two things:
|
inlineexplicit |
Construct a new CountingSemaphore by calling SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount)
maxCount | The maximum count value that can be reached. When the semaphore reaches this value it can no longer be 'given'. |
initialCount | The count value assigned to the semaphore when it is created. |