EtcPal  0.4.1
ETC Platform Abstraction Layer (EtcPal)
View other versions:
Queue< T > Class Template Reference

Overview

template<class T>
class etcpal::Queue< T >

An RTOS queue class.

See the module description for queue (RTOS queues) for usage information.

Public Member Functions

 Queue (size_t size)
 Create a new queue. More...
 
 ~Queue ()
 Destroy a queue.
 
 Queue (const Queue &other)=delete
 
Queueoperator= (const Queue &other)=delete
 
 Queue (Queue &&other)=delete
 
Queueoperator= (Queue &&other)=delete
 
bool Send (const T &data, int timeout_ms=ETCPAL_WAIT_FOREVER)
 Add some data to the queue. More...
 
bool SendFromIsr (const T &data)
 Add to a queue from an interrupt service routine. More...
 
bool Receive (T &data, int timeout_ms=ETCPAL_WAIT_FOREVER)
 Get an item from the queue. More...
 
template<class Rep , class Period >
bool Receive (T &data, const std::chrono::duration< Rep, Period > &timeout)
 Get an item from the queue. More...
 
bool ReceiveFromIsr (T &data)
 Get an item from the queue from an interrupt context. More...
 
bool Reset ()
 Resets queue to empty state. More...
 
bool IsEmpty () const
 Check if a queue is empty. More...
 
bool IsEmptyFromIsr () const
 Check if a queue is empty from an interrupt service routine. More...
 
bool IsFull () const
 Check if a queue is full. More...
 
bool IsFullFromIsr () const
 Check if a queue is full from an interrupt service routine. More...
 
size_t SlotsUsed () const
 Get number of slots being stored in the queue. More...
 
size_t SlotsUsedFromIsr () const
 Get number of slots being stored in the queue from an interrupt service routine. More...
 
size_t SlotsAvailable () const
 Get number of remaining slots in the queue. More...
 

Constructor & Destructor Documentation

◆ Queue()

Queue ( size_t  size)
inlineexplicit

Create a new queue.

Parameters
sizeThe size of the queue.

Member Function Documentation

◆ IsEmpty()

bool IsEmpty
inline

Check if a queue is empty.

Returns
true if queue is empty, false otherwise.

◆ IsEmptyFromIsr()

bool IsEmptyFromIsr
inline

Check if a queue is empty from an interrupt service routine.

Returns
true if queue is empty, false otherwise.

◆ IsFull()

bool IsFull
inline

Check if a queue is full.

Returns
true if queue is full, false otherwise.

◆ IsFullFromIsr()

bool IsFullFromIsr
inline

Check if a queue is full from an interrupt service routine.

Returns
true if queue is full, false otherwise.

◆ Receive() [1/2]

bool Receive ( T &  data,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Get an item from the queue.

Parameters
dataA reference to the data that will receive the item from the queue.
timeoutAmount of time to wait for data.
Returns
The result of the attempt to get an item from the queue.

◆ Receive() [2/2]

bool Receive ( T &  data,
int  timeout_ms = ETCPAL_WAIT_FOREVER 
)
inline

Get an item from the queue.

Parameters
dataA reference to the data that will receive the item from the queue.
timeout_msAmount of time to wait for data.
Returns
The result of the attempt to get an item from the queue.

◆ ReceiveFromIsr()

bool ReceiveFromIsr ( T &  data)
inline

Get an item from the queue from an interrupt context.

Parameters
dataA reference to the data that will receive the item from the queue.
Returns
The result of the attempt to get an item from the queue.

◆ Reset()

bool Reset
inline

Resets queue to empty state.

Returns
true on success, false otherwise.

◆ Send()

bool Send ( const T &  data,
int  timeout_ms = ETCPAL_WAIT_FOREVER 
)
inline

Add some data to the queue.

Returns when either the timeout expires or the add was attempted. It is still possible for the attempt to be made and the add to not work. Check the return value for confirmation.

Parameters
dataA reference to the data.
timeout_msHow long to wait to add to the queue.
Returns
The result of the attempt to add to the queue.

◆ SendFromIsr()

bool SendFromIsr ( const T &  data)
inline

Add to a queue from an interrupt service routine.

Parameters
dataA reference to the data to be added to the queue.
Returns
The result of the attempt to add to the queue.

◆ SlotsAvailable()

size_t SlotsAvailable
inline

Get number of remaining slots in the queue.

Returns
number of remaining slots in queue.

◆ SlotsUsed()

size_t SlotsUsed
inline

Get number of slots being stored in the queue.

Returns
number of slots in queue.

◆ SlotsUsedFromIsr()

size_t SlotsUsedFromIsr
inline

Get number of slots being stored in the queue from an interrupt service routine.

Returns
number of slots in queue.

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