1.2.12.4.6 SRV_QUEUE_Read_Or_Remove Function
C
SRV_QUEUE_ELEMENT *SRV_QUEUE_Read_Or_Remove( SRV_QUEUE *queue, SRV_QUEUE_MODE accessMode, SRV_QUEUE_POSITION position );
Summary
Reads or removes an element from a queue.
Description
This function reads or removes an element from a queue.
Precondition
The queue must have been initialized previously with function SRV_QUEUE_Init.
Parameters
Param | Description |
---|---|
queue | Pointer to the queue from which the element must be read or removed |
accessMode | Access mode (read or remove) |
position | Position in the queue to read or remove (head or tail) |
Returns
- In case of remove, the element will be removed from queue and returned.
- In case of read, the element will be returned without removing it from the queue.
- If the queue is empty, NULL is returned.
Example
#define NUM_MAX_NODES 750 typedef struct _node_info_tag { struct _node_info_tag *prev; struct _node_info_tag *next; uint8_t macAddress[8] } NODE_INFO; static SRV_QUEUE nodeQueue; static NODE_INFO nodeInfo; NODE_INFO *removedNode; SRV_QUEUE_Init(&nodeQueue, NUM_MAX_NODES, SRV_QUEUE_TYPE_SINGLE); memset(nodeInfo.macAddress, 0xFF, 8); SRV_QUEUE_Append(&nodeQueue, (SRV_QUEUE_ELEMENT *)&nodeInfo); removedNode = SRV_QUEUE_Read_Or_Remove(&nodeQueue, SRV_QUEUE_MODE_REMOVE, SRV_QUEUE_POSITION_HEAD);
Remarks
None.