COSA
An Object-Oriented Platform for Arduino Programming
Queue< T, NMEMB > Class Template Reference

#include <Queue.hh>

Inheritance diagram for Queue< T, NMEMB >:
Inheritance graph
Collaboration diagram for Queue< T, NMEMB >:
Collaboration graph

Public Member Functions

 Queue ()
 
uint8_t available () const
 
uint8_t room () const
 
bool enqueue (T *data)
 
bool enqueue_P (const T *data)
 
bool dequeue (T *data)
 
void await (T *data)
 

Detailed Description

template<class T, uint8_t NMEMB>
class Queue< T, NMEMB >

Template class for ring-buffer for queueing data elements. See Event::queue for an example of usage.

Parameters
[in]Telement class.
[in]nmembnumber of elements in queue.
Precondition
nmemb is powerof(2) and max 128.

Definition at line 35 of file Queue.hh.

Constructor & Destructor Documentation

template<class T, uint8_t NMEMB>
Queue< T, NMEMB >::Queue ( )
inline

Construct a ring-buffer queue with given number of members member type.

Definition at line 42 of file Queue.hh.

Member Function Documentation

template<class T, uint8_t NMEMB>
uint8_t Queue< T, NMEMB >::available ( ) const
inline

Return number of elements in queue.

Returns
available elements.

Definition at line 51 of file Queue.hh.

template<class T, uint8_t NMEMB>
void Queue< T, NMEMB >::await ( T *  data)

Await data to become available from queue. Will perform a system sleep with the given sleep mode.

Parameters
[in,out]datapointer to member data buffer.
Precondition
data != NULL
Note
atomic

Definition at line 158 of file Queue.hh.

template<class T, uint8_t NMEMB>
bool Queue< T, NMEMB >::dequeue ( T *  data)

Dequeue member data from queue to given buffer. Returns true(1) if member was available and succcessful otherwise false(0). Synchronised operation as interrupt handler may push events.

Parameters
[in,out]datapointer to member data buffer.
Precondition
data != NULL
Returns
boolean.
Note
atomic

Definition at line 145 of file Queue.hh.

template<class T, uint8_t NMEMB>
bool Queue< T, NMEMB >::enqueue ( T *  data)

Enqueue given member data if storage is available. Return true(1) if successful otherwise false(0). Synchronised operation as interrupt handler may push events.

Parameters
[in]datapointer to member data buffer.
Returns
boolean.
Precondition
data != NULL
Note
atomic

Definition at line 119 of file Queue.hh.

template<class T, uint8_t NMEMB>
bool Queue< T, NMEMB >::enqueue_P ( const T *  data)

Enqueue given member data in program memory if storage is available. Return true(1) if successful otherwise false(0). Synchronised operation as interrupt handler may push events.

Parameters
[in]datapointer to member data buffer in program memory.
Returns
boolean.
Precondition
data != NULL
Note
atomic

Definition at line 132 of file Queue.hh.

template<class T, uint8_t NMEMB>
uint8_t Queue< T, NMEMB >::room ( ) const
inline

Number of elements room in queue.

Returns
room for elements.

Definition at line 61 of file Queue.hh.


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