API interface to create and handle Queues.
More...
|
#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.
|
|
|
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.
|
|
API interface to create and handle Queues.
◆ qQueue_Count()
size_t qQueue_Count |
( |
const qQueue_t *const | q | ) |
|
Returns the number of items in the Queue.
- Parameters
-
[in] | q | A pointer to the Queue object |
- Returns
- The number of elements in the queue
◆ qQueue_IsEmpty()
Returns the empty status of the Queue.
- Parameters
-
[in] | q | A pointer to the Queue object |
- Returns
- qTrue if the Queue is empty, qFalse if it is not.
◆ qQueue_IsFull()
Returns the full status of the Queue.
- Parameters
-
[in] | q | A pointer to the Queue object |
- Returns
- qTrue if the Queue is full, qFalse if it is not.
◆ qQueue_IsReady()
Check if the queue is already initialized by using qQueue_Setup() API.
- Parameters
-
[in] | q | A 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] | q | A 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] | q | A pointer to the Queue object |
- Returns
- Pointer to the data, or
NULL
if there is nothing in the queue.
◆ qQueue_Receive()
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] | q | A pointer to the Queue object |
[out] | dst | Pointer 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()
Remove the data located at the front of the Queue.
- Parameters
-
[in] | q | A pointer to the Queue object |
- Returns
- qTrue if data was removed from the Queue, otherwise returns qFalse
◆ qQueue_Reset()
Resets a queue to its original empty state.
- Parameters
-
[in] | q | A pointer to the Queue object |
- Returns
- qTrue on success, otherwise returns qFalse.
◆ qQueue_Send()
Post an item to the the queue. The item is queued by copy, not by reference.
- Parameters
-
[in] | q | A pointer to the Queue object |
[in] | itemToQueue | A 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] | pos | Can 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] | q | A pointer to the Queue object |
[in] | pData | Data block or array of data. |
[in] | itemSize | The size, in bytes, of one single item in the queue. |
[in] | itemsCount | The maximum number of items the queue can hold. |
- Returns
- qTrue on success, otherwise returns qFalse.
◆ qTask_Attach_Queue()
Attach a Queue to the Task.
- Parameters
-
[in] | Task | Pointer to the task node. |
[in] | q | A pointer to a Queue object |
[in] | mode | Attach 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] | arg | This 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.