mn::queue::basic_queue Class Reference

Queue class wrapper for FreeRTOS queues. More...

#include <mn_queue.hpp>

+ Inheritance diagram for mn::queue::basic_queue:

Public Member Functions

 basic_queue (unsigned int maxItems, unsigned int itemSize)
 
virtual ~basic_queue ()
 
virtual int create ()
 
virtual int destroy ()
 
virtual int enqueue (void *item, unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT)
 
virtual int peek (void *item, unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT)
 
virtual int dequeue (void *item, unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT)
 
virtual bool is_empty ()
 
virtual bool is_full ()
 
virtual int clear ()
 
virtual unsigned int get_num_items ()
 
virtual unsigned int get_left ()
 
void * get_handle ()
 

Protected Attributes

void * m_pHandle
 
unsigned int m_imaxItems
 
unsigned int m_iitemSize
 

Detailed Description

Queue class wrapper for FreeRTOS queues.

Note
can use at the ISR Context, too. This wrapper switch automatic

Constructor & Destructor Documentation

◆ basic_queue()

mn::queue::basic_queue::basic_queue ( unsigned int  maxItems,
unsigned int  itemSize 
)

ctor

Parameters
maxItemsMaximum number of items this queue can hold.
itemSizeSize of an item in a queue.

◆ ~basic_queue()

mn::queue::basic_queue::~basic_queue ( )
virtual

dtor

Member Function Documentation

◆ clear()

int mn::queue::basic_queue::clear ( )
virtual

Remove all objects from the queue.

◆ create()

int mn::queue::basic_queue::create ( )
virtual

Create the queue

Returns
'ERR_QUEUE_OK': the queue was created 'ERR_QUEUE_ALREADYINIT': the queue is allready created 'ERR_QUEUE_CANTCREATE': queue can not created
Note
FreeRTOS queues use a memcpy / fixed size scheme for queues.

◆ dequeue()

int mn::queue::basic_queue::dequeue ( void *  item,
unsigned int  timeout = MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT 
)
virtual

Remove an item from the front of the queue.

Parameters
itemWhere the item you are removing will be returned to.
timeoutHow long to wait to remove an item to the queue.
Returns
'ERR_QUEUE_OK' the item was removed, 'ERR_QUEUE_REMOVE' on an error and 'ERR_QUEUE_NOTCREATED' when the queue not created

◆ destroy()

int mn::queue::basic_queue::destroy ( )
virtual

Destroy the Queue

Returns
'ERR_QUEUE_OK' the queue was destroyed 'ERR_QUEUE_NOTCREATED' the queue is not created

◆ enqueue()

int mn::queue::basic_queue::enqueue ( void *  item,
unsigned int  timeout = MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT 
)
virtual

Add an item to the back of the queue.

Parameters
itemThe item you are adding.
timeoutHow long to wait to add the item to the queue
Returns
'ERR_QUEUE_OK' the item was added, 'ERR_QUEUE_ADD' on an error and 'ERR_QUEUE_NOTCREATED' when the queue not created

Reimplemented in mn::queue::basic_binaryqueue.

◆ get_handle()

void* mn::queue::basic_queue::get_handle ( )
inline

get the FreeRTOS queue handle

Returns
the FreeRTOS handle

◆ get_left()

unsigned int mn::queue::basic_queue::get_left ( )
virtual

How many empty spaves are currently left in the queue.

Returns
the number of remaining spaces.

◆ get_num_items()

unsigned int mn::queue::basic_queue::get_num_items ( )
virtual

How many items are currently in the queue.

Returns
the number of items in the queue.

◆ is_empty()

bool mn::queue::basic_queue::is_empty ( )
virtual

Is the queue empty?

Returns
true the queue is empty and false when not

◆ is_full()

bool mn::queue::basic_queue::is_full ( )
virtual

Is the queue full?

Returns
true the queue is full and false when not

◆ peek()

int mn::queue::basic_queue::peek ( void *  item,
unsigned int  timeout = MN_THREAD_CONFIG_TIMEOUT_QUEUE_DEFAULT 
)
virtual

Make a copy of an item from the front of the queue. This will not remove it

Parameters
itemWhere the item you are getting will be returned to.
timeoutHow long to wait
Returns
'ERR_QUEUE_OK' if an item was copied, 'ERR_QUEUE_PEEK' on error and 'ERR_QUEUE_NOTCREATED' when the queue not created

Member Data Documentation

◆ m_iitemSize

unsigned int mn::queue::basic_queue::m_iitemSize
protected

◆ m_imaxItems

unsigned int mn::queue::basic_queue::m_imaxItems
protected

◆ m_pHandle

void* mn::queue::basic_queue::m_pHandle
protected

FreeRTOS queue handle.


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