OS_MSG_QTY OSQFlush (OS_Q *p_q,
OS_ERR *p_err)
File | Called from | Code enabled by |
---|---|---|
| Task only |
|
...
Description
Empties the contents of the message queue and eliminates all messages sent to the queue. This function takes the same amount of time to execute regardless of whether tasks are waiting on the queue (and thus no messages are present), or the queue contains one or more messages. OS_MSGs
from the queue are simply returned to the free pool of OS_MSGs
.
Files
os.h/os_q.c
Prototype
Arguments
p_q
is a pointer to the message queue.
...
The number of OS_MSG
entries freed from the message queue. Note that the OS_MSG
entries are returned to the free pool of OS_MSGs
.
Required Configuration
OS_CFG_Q_EN
and OS_CFG_Q_FLUSH_EN
must be enabled in os_cfg.h. Refer to uC-OS-III Configuration Manual
Callers
Application.
Notes/Warnings
- Queues must be created before they are used.
- Use this function with great care. When flushing a queue, you lose the references to what the queue entries are pointing to, potentially causing 'memory leaks'. The data that the user is pointing to that is referenced by the queue entries should, most likely, be de-allocated (i.e., freed).
Example Usage
or, to flush a queue that contains entries, instead you can use OSQPend()
and specify the OS_OPT_PEND_NON_BLOCKING
option.