EtcPal  0.3.0
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.
 
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 IsEmpty () const
 Check if a queue is empty. More...
 
bool IsEmptyFromIsr () const
 Check if a queue is empty from an interrupt service routine. 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.

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

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

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