Miosix  2.0alpha1
miosix::Queue< T, len > Class Template Reference

#include <queue.h>

Public Member Functions

 Queue ()
 
bool isEmpty () const
 
bool isFull () const
 
unsigned int size () const
 
unsigned int capacity () const
 
void waitUntilNotEmpty ()
 
void waitUntilNotFull ()
 
void get (T &elem)
 
void put (const T &elem)
 
bool IRQget (T &elem)
 
bool IRQget (T &elem, bool &hppw)
 
bool IRQput (const T &elem)
 
bool IRQput (const T &elem, bool &hppw)
 
void reset ()
 
void IRQreset ()
 

Detailed Description

template<typename T, unsigned int len>
class miosix::Queue< T, len >

A queue, used to transfer data between TWO threads, or between ONE thread and an IRQ.
If you need to tranfer data between more than two threads, you need to use mutexes to ensure that only one thread at a time calls get, and only one thread at a time calls put.
Dynamically creating a queue with new or on the stack must be done with care, to avoid deleting a queue with a waiting thread, and to avoid situations where a thread tries to access a deleted queue.

Template Parameters
Tthe type of elements in the queue
lenthe length of the Queue. Value 0 is forbidden

Constructor & Destructor Documentation

template<typename T , unsigned int len>
miosix::Queue< T, len >::Queue ( )
inline

Constructor, create a new empty queue.

Member Function Documentation

template<typename T , unsigned int len>
unsigned int miosix::Queue< T, len >::capacity ( ) const
inline
Returns
the maximum number of elements the queue can hold
template<typename T , unsigned int len>
void miosix::Queue< T, len >::IRQreset ( )
inline

Same as reset(), but to be used only inside IRQs or when interrupts are disabled.

template<typename T , unsigned int len>
bool miosix::Queue< T, len >::isEmpty ( ) const
inline
Returns
true if the queue is empty
template<typename T , unsigned int len>
bool miosix::Queue< T, len >::isFull ( ) const
inline
Returns
true if the queue is full
template<typename T , unsigned int len>
void miosix::Queue< T, len >::reset ( )
inline

Clear all items in the queue.
Cannot be used inside an IRQ

template<typename T , unsigned int len>
unsigned int miosix::Queue< T, len >::size ( ) const
inline
Returns
the number of elements currently in the queue

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