Skip to content

Commit 34813ed

Browse files
author
Seppo Takalo
authored
Merge pull request #11145 from Tharazi97/CountFunctionQueue
Implement queue.count()
2 parents dd2d585 + 32bdde5 commit 34813ed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

rtos/Queue.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
107107
return osMessageQueueGetSpace(_id) == 0;
108108
}
109109

110+
/** Get number of queued messages in the queue.
111+
*
112+
* @return Number of items in the queue
113+
*
114+
* @note You may call this function from ISR context.
115+
*/
116+
uint32_t count() const
117+
{
118+
return osMessageQueueGetCount(_id);
119+
}
120+
110121
/** Inserts the given element to the end of the queue.
111122
*
112123
* This function puts the message pointed to by `data` into the queue. The

0 commit comments

Comments
 (0)