QUE_get
2-344
C Interface
Syntax
elem = QUE_get(queue);
Parameters
QUE_Handle queue;
/* queue object handle */
Return Value
Void
*elem;
/* pointer to former first element */
Description
QUE_get removes the element from the front of queue and returns elem.
The return value, elem, is a pointer to the element at the front of the QUE.
Such elements have a structure defined similarly to that in the example
in the QUE Module topic. The first field in the structure must be of type
QUE_Elem and is used as an internal pointer.
Since QUE_get manipulates the queue with interrupts disabled, the
queue can be shared by multiple tasks, or by tasks and SWIs or HWIs.
Calling QUE_get with an empty queue returns the queue itself. This
provides a means for using a single atomic action to check if a queue is
empty, and to remove and return the first element if it is not empty:
if ((QUE_Handle)(elem = QUE_get(q)) != q)
` process elem `
Note:
Use QUE_get instead of QUE_dequeue if multiple threads share a
queue. QUE_get is never interrupted; QUE_dequeue performs the
same action but runs non-atomically. You can use QUE_dequeue if
you disable interrupts or use a synchronization mechanism such as
LCK or SEM to protect the queue.
QUE_dequeue is somewhat faster than QUE_get, but you should not
use it unless you know your QUE operation cannot be preempted by
another thread that operates on the same queue.
See Also
QUE_get
Get element from front of queue (atomically)