From 32bdde5b8ea60b0a73f6981f839814cf3f824ea0 Mon Sep 17 00:00:00 2001 From: int_szyk Date: Thu, 1 Aug 2019 11:17:27 +0200 Subject: [PATCH] Add queue.count() in Queue.h --- rtos/Queue.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rtos/Queue.h b/rtos/Queue.h index 7e0149634f..8599e3c0d7 100644 --- a/rtos/Queue.h +++ b/rtos/Queue.h @@ -107,6 +107,17 @@ public: return osMessageQueueGetSpace(_id) == 0; } + /** Get number of queued messages in the queue. + * + * @return Number of items in the queue + * + * @note You may call this function from ISR context. + */ + uint32_t count() const + { + return osMessageQueueGetCount(_id); + } + /** Inserts the given element to the end of the queue. * * This function puts the message pointed to by `data` into the queue. The