Skip to content

Commit 32bdde5

Browse files
committed
Add queue.count() in Queue.h
1 parent 2f136b9 commit 32bdde5

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)