OS  v7.3.3
Documentation
Loading...
Searching...
No Matches

API interface to create and handle Queues. More...

Collaboration diagram for Queues:

Data Structures

struct  qQueue_t
 A Queue object. More...
 

Macros

#define QUEUE_SEND_TO_BACK
 A macro directive to indicate whether the item in the queue should be sent to the back.
 
#define QUEUE_SEND_TO_FRONT
 A macro directive to indicate whether the item in the queue should be sent to the front.
 

Typedefs

typedef qUINT8_t qQueue_InsertMode_t
 A typedef to indicate the queue send mode : QUEUE_SEND_TO_BACK or QUEUE_SEND_TO_FRONT.
 

Functions

qBool_t qQueue_IsReady (const qQueue_t *const q)
 Check if the queue is already initialized by using qQueue_Setup() API.
 
qBool_t qQueue_Setup (qQueue_t *const q, void *pData, const size_t itemSize, const size_t itemsCount)
 Configures a Queue. Here, the RAM used to hold the queue data pData is statically allocated at compile time by the application writer.
 
qBool_t qQueue_Reset (qQueue_t *const q)
 Resets a queue to its original empty state.
 
qBool_t qQueue_IsEmpty (const qQueue_t *const q)
 Returns the empty status of the Queue.
 
size_t qQueue_Count (const qQueue_t *const q)
 Returns the number of items in the Queue.
 
size_t qQueue_ItemsAvailable (const qQueue_t *const q)
 Returns the number of available slots to hold items inside the queue.
 
qBool_t qQueue_IsFull (const qQueue_t *const q)
 Returns the full status of the Queue.
 
void * qQueue_Peek (const qQueue_t *const q)
 Looks at the data from the front of the Queue without removing it.
 
qBool_t qQueue_RemoveFront (qQueue_t *const q)
 Remove the data located at the front of the Queue.
 
qBool_t qQueue_Receive (qQueue_t *const q, void *dst)
 Receive an item from a queue (and removes it). The item is received by copy so a buffer of adequate size must be provided. The number of bytes copied into the buffer was defined when the queue was created.
 
qBool_t qQueue_Send (qQueue_t *const q, void *itemToQueue, const qQueue_InsertMode_t pos)
 Post an item to the the queue. The item is queued by copy, not by reference.
 
qBool_t qTask_Attach_Queue (qTask_t *const Task, qQueue_t *const q, const qQueueLinkMode_t mode, const qUINT16_t arg)
 Attach a Queue to the Task.
 

Detailed Description

API interface to create and handle Queues.

Function Documentation

◆ qQueue_Count()

size_t qQueue_Count ( const qQueue_t *const q)

Returns the number of items in the Queue.

Parameters
[in]qA pointer to the Queue object
Returns
The number of elements in the queue

◆ qQueue_IsEmpty()

qBool_t qQueue_IsEmpty ( const qQueue_t *const q)

Returns the empty status of the Queue.

Parameters
[in]qA pointer to the Queue object
Returns
qTrue if the Queue is empty, qFalse if it is not.

◆ qQueue_IsFull()

qBool_t qQueue_IsFull ( const qQueue_t *const q)

Returns the full status of the Queue.

Parameters
[in]qA pointer to the Queue object
Returns
qTrue if the Queue is full, qFalse if it is not.

◆ qQueue_IsReady()

qBool_t qQueue_IsReady ( const qQueue_t *const q)

Check if the queue is already initialized by using qQueue_Setup() API.

Parameters
[in]qA pointer to the Queue object
Returns
qTrue if the queue is initialized, qFalse if not.

◆ qQueue_ItemsAvailable()

size_t qQueue_ItemsAvailable ( const qQueue_t *const q)

Returns the number of available slots to hold items inside the queue.

Parameters
[in]qA pointer to the Queue object
Returns
The number of available slots in the queue.

◆ qQueue_Peek()

void * qQueue_Peek ( const qQueue_t *const q)

Looks at the data from the front of the Queue without removing it.

Parameters
[in]qA pointer to the Queue object
Returns
Pointer to the data, or NULL if there is nothing in the queue.

◆ qQueue_Receive()

qBool_t qQueue_Receive ( qQueue_t *const q,
void * dst )

Receive an item from a queue (and removes it). The item is received by copy so a buffer of adequate size must be provided. The number of bytes copied into the buffer was defined when the queue was created.

Parameters
[in]qA pointer to the Queue object
[out]dstPointer to the buffer into which the received item will be copied.
Returns
qTrue if data was retrieved from the Queue, otherwise returns qFalse

◆ qQueue_RemoveFront()

qBool_t qQueue_RemoveFront ( qQueue_t *const q)

Remove the data located at the front of the Queue.

Parameters
[in]qA pointer to the Queue object
Returns
qTrue if data was removed from the Queue, otherwise returns qFalse

◆ qQueue_Reset()

qBool_t qQueue_Reset ( qQueue_t *const q)

Resets a queue to its original empty state.

Parameters
[in]qA pointer to the Queue object
Returns
qTrue on success, otherwise returns qFalse.

◆ qQueue_Send()

qBool_t qQueue_Send ( qQueue_t *const q,
void * itemToQueue,
const qQueue_InsertMode_t pos )

Post an item to the the queue. The item is queued by copy, not by reference.

Parameters
[in]qA pointer to the Queue object
[in]itemToQueueA pointer to the item that is to be placed on the queue. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from itemToQueue into the queue storage area.
[in]posCan take the value QUEUE_SEND_TO_BACK to place the item at the back of the queue, or QUEUE_SEND_TO_FRONT to place the item at the front of the queue (for high priority messages).
Returns
qTrue on successful add, qFalse if not added

◆ qQueue_Setup()

qBool_t qQueue_Setup ( qQueue_t *const q,
void * pData,
const size_t itemSize,
const size_t itemsCount )

Configures a Queue. Here, the RAM used to hold the queue data pData is statically allocated at compile time by the application writer.

Parameters
[in]qA pointer to the Queue object
[in]pDataData block or array of data.
[in]itemSizeThe size, in bytes, of one single item in the queue.
[in]itemsCountThe maximum number of items the queue can hold.
Returns
qTrue on success, otherwise returns qFalse.

◆ qTask_Attach_Queue()

qBool_t qTask_Attach_Queue ( qTask_t *const Task,
qQueue_t *const q,
const qQueueLinkMode_t mode,
const qUINT16_t arg )

Attach a Queue to the Task.

Parameters
[in]TaskPointer to the task node.
[in]qA pointer to a Queue object
[in]modeAttach mode. This implies the event that will trigger the task according to one of the following modes:

qQueueMode_Receiver : The task will be triggered if there are elements in the Queue. Data will be extracted automatically in every trigger and will be available in the qEvent_t::EventData field.

qQueueMode_Full : The task will be triggered if the Queue is full. A pointer to the queue will be available in the qEvent_t::EventData field.

qQueueMode_Count : The task will be triggered if the count of elements in the queue reach the specified value. A pointer to the queue will be available in the qEvent_t::EventData field.

qQueueMode_Empty : The task will be triggered if the queue is empty. A pointer to the queue will be available in the qEvent_t::EventData field.

Parameters
[in]argThis argument defines if the queue will be attached (qLink) or detached (qUnLink) from the task. If the qQueueMode_Count mode is specified, this value will be used to check the element count of the queue. A zero value will act as a qUnLink action.
Returns
Returns qTrue on success, otherwise returns qFalse.