The docs do not explicitly mention if a successfully received (get()
) message is then wiped from the queue, aka "consumed". Is this unclear in the docs or do i have to delete the message manually? If so, how can i achieve that?
-
\$\begingroup\$ The semantics of the queue would suggest the former is true, and it is not a "hole", it is implied. \$\endgroup\$– Eugene Sh.Commented Mar 3, 2022 at 15:55
-
1\$\begingroup\$ It seems like it would be a strange queue if the message is not consumed and has to be deleted manually by a process which is not mentioned in the documentation. Also, is the source not available? Can you not check the source? \$\endgroup\$– user57037Commented Mar 3, 2022 at 17:05
1 Answer
As mentioned in the comments, receiving or getting an item from the queue implies that the item is removed from the queue. The usage example is provided in the documentation of osMessageQueuePut
.
Typically, there is not a separate API to remove a single item from a queue, if you want to do that, just receive the item and do nothing with it.
osMessageQueueReset
would clear all items, while osMessageQueueDelete
deletes the queue itself.
Some APIs do have ability to get an item from the queue without removing it. Typically, such API would use a term "peek". CMSIS-RTOS2 API does not seem to have such a function, but you can see FreeRTOS xQueuePeek
for an example.
-
1\$\begingroup\$ Using
osMessageQueueGetCount()
reveals that the queue indeed decrements the number of its messages after a successfulget()
. I had overlooked this function, my bad. Thanks for your response. \$\endgroup\$ Commented Mar 4, 2022 at 7:05