QUE_remove
Application Program Interface
2-351
C Interface
Syntax
QUE_remove(qelem);
Parameters
Ptr
qelem;
/* element in queue */
Return Value
Void
Description
QUE_remove removes qelem from the queue.
The qelem parameter is a pointer to an existing element to be removed
from 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 queues are implemented as doubly linked lists with a dummy
node at the head, be careful not to remove the header node. This can
happen when qelem is the return value of QUE_next or QUE_prev. The
following code sample shows how qelem should be verified before calling
QUE_remove.
QUE_Elem *qelem;.
/* get pointer to first element in the queue */
qelem = QUE_head(queue);
/* scan entire queue for desired element */
while (qelem != queue) {
if(‘ qelem is the elem we’re looking for ‘) {
break;
}
qelem = QUE_next(qelem);
}
/* make sure qelem is not the queue itself */
if (qelem != queue) {
QUE_remove(qelem);
}
Note:
If the queue is shared by multiple tasks, or tasks and SWIs or HWIs,
QUE_remove should be used in conjunction with some mutual
exclusion mechanism (for example, SEM_pend/SEM_post,
TSK_disable/ TSK_enable).
QUE_remove
Remove from middle of queue (non-atomically)