FreeRTOS-Cpp
Public Member Functions | List of all members
FreeRTOS::Queue< T > Class Template Reference

Class that encapsulates the functionality of a FreeRTOS queue. More...

#include <FreeRTOS/Queue.hpp>

Inheritance diagram for FreeRTOS::Queue< T >:
Inheritance graph
[legend]
Collaboration diagram for FreeRTOS::Queue< T >:
Collaboration graph
[legend]

Public Member Functions

 Queue (const UBaseType_t length)
 Construct a new Queue object by calling QueueHandle_t xQueueCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize ) More...
 
 Queue (const Queue &)=delete
 
Queueoperator= (const Queue &)=delete
 
 Queue (Queue &&) noexcept=default
 
Queueoperator= (Queue &&) noexcept=default
 
- Public Member Functions inherited from FreeRTOS::QueueBase< T >
 QueueBase (const QueueBase &)=delete
 
QueueBaseoperator= (const QueueBase &)=delete
 
bool isValid () const
 Function that checks if the underlying queue handle is not NULL. This should be used to ensure a queue has been created correctly. More...
 
bool sendToBack (const T &item, const TickType_t ticksToWait=portMAX_DELAY) const
 Function that calls xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) More...
 
bool sendToBackFromISR (bool &higherPriorityTaskWoken, const T &item) const
 Function that calls xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More...
 
bool sendToBackFromISR (const T &item) const
 Function that calls xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More...
 
bool sendToFront (const T &item, const TickType_t ticksToWait=portMAX_DELAY) const
 Function that calls xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) More...
 
bool sendToFrontFromISR (bool &higherPriorityTaskWoken, const T &item) const
 Function that calls xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More...
 
bool sendToFrontFromISR (const T &item) const
 Function that calls xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) More...
 
std::optional< T > receive (const TickType_t ticksToWait=portMAX_DELAY) const
 Function that calls BaseType_t xQueueReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ) More...
 
std::optional< T > receiveFromISR (bool &higherPriorityTaskWoken) const
 Function that calls BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxHigherPriorityTaskWoken ) More...
 
std::optional< T > receiveFromISR () const
 Function that calls BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxHigherPriorityTaskWoken ) More...
 
UBaseType_t messagesWaiting () const
 Function that calls UBaseType_t uxQueueMessagesWaiting( QueueHandle_t xQueue ) More...
 
UBaseType_t messagesWaitingFromISR () const
 Function that calls UBaseType_t uxQueueMessagesWaitingFromISR( QueueHandle_t xQueue ) More...
 
UBaseType_t spacesAvailable () const
 Function that calls UBaseType_t uxQueueSpacesAvailable( QueueHandle_t xQueue ) More...
 
void reset () const
 Function that calls BaseType_t xQueueReset( QueueHandle_t xQueue ) More...
 
void overwrite (const T &item) const
 Function that calls BaseType_t xQueueOverwrite( QueueHandle_t xQueue, const void * pvItemToQueue ) More...
 
void overwriteFromISR (bool &higherPriorityTaskWoken, const T &item) const
 Function that calls BaseType_t xQueueOverwriteFromISR( QueueHandle_t xQueue, const void * pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken ) More...
 
void overwriteFromISR (const T &item) const
 Function that calls BaseType_t xQueueOverwriteFromISR( QueueHandle_t xQueue, const void * pvItemToQueue, BaseType_t *pxHigherPriorityTaskWoken ) More...
 
std::optional< T > peek (const TickType_t ticksToWait=portMAX_DELAY) const
 Function that calls BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) More...
 
std::optional< T > peekFromISR () const
 Function that calls BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void *pvBuffer ) More...
 
void addToRegistry (const char *name) const
 Function that calls void vQueueAddToRegistry( QueueHandle_t xQueue, char *pcQueueName ) More...
 
void unregister () const
 Function that calls void vQueueUnregisterQueue( QueueHandle_t xQueue ) More...
 
const char * getName () const
 Function that calls const char *pcQueueGetName( QueueHandle_t xQueue ) More...
 
bool isFullFromISR () const
 Function that calls BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) More...
 
bool isEmptyFromISR () const
 Function that calls BaseType_t xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from FreeRTOS::QueueBase< T >
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
 

Detailed Description

template<class T>
class FreeRTOS::Queue< T >

Class that encapsulates the functionality of a FreeRTOS queue.

Each queue requires RAM that is used to hold the queue state, and to hold the items that are contained in the queue (the queue storage area). If a queue is created using this class then the required RAM is automatically allocated from the FreeRTOS heap.

Template Parameters
TType to be stored in the queue.

Constructor & Destructor Documentation

◆ Queue()

template<class T >
FreeRTOS::Queue< T >::Queue ( const UBaseType_t  length)
inlineexplicit

Construct a new Queue object by calling QueueHandle_t xQueueCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize )

Queue.hpp

See also
https://www.freertos.org/a00116.html
Warning
The user should call isValid() on this object to verify that the queue was created successfully in case the memory required to create the queue could not be allocated.
Parameters
lengthThe maximum number of items the queue can hold at any one time.

Example Usage

#include <FreeRTOS/Queue.hpp>
#include <FreeRTOS/Task.hpp>
class MyTask : public FreeRTOS::Task {
public:
void taskFunction() final;
};
class Message {
public:
char ucMessageID;
char ucData[20];
} xMessage;
void MyTask::taskFunction() {
// Create a queue capable of containing 10 unsigned long values.
if (!queue1.isValid()) {
// Queue was not created and must not be used.
}
// Create a queue capable of containing 10 pointers to Message objects. These
// should be passed by pointer as they contain a lot of data
if (!queue2.isValid()) {
// Queue was not created and must not be used.
}
// Rest of task code.
}
Class that encapsulates the functionality of a FreeRTOS queue.
Definition: Queue.hpp:649
Class that encapsulates the functionality of a FreeRTOS task.
Definition: Task.hpp:1323

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