Skip to content

Commit cf2378e

Browse files
committed
Added empty, full function to Queue and Mail
1 parent 003dd7c commit cf2378e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

rtos/Mail.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
5454
/** Create and Initialise Mail queue. */
5555
Mail() { };
5656

57+
/** Check if the mail queue is empty
58+
*
59+
* @return True if the mail queue is mail, false if not
60+
*/
61+
bool empty() const {
62+
return _queue.empty();
63+
}
64+
65+
/** Check if the mail queue is full
66+
*
67+
* @return True if the mail queue is full, false if not
68+
*/
69+
bool full() const {
70+
return _queue.full();
71+
}
72+
5773
/** Allocate a memory block of type T
5874
@param millisec timeout value or 0 in case of no time-out. (default: 0).
5975
@return pointer to memory block that can be filled with mail or NULL in case error.

rtos/Queue.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
6464
osMessageQueueDelete(_id);
6565
}
6666

67+
/** Check if the queue is empty
68+
*
69+
* @return True if the queue is empty, false if not
70+
*/
71+
bool empty() const {
72+
return osMessageQueueGetCount(_id) == 0;
73+
}
74+
75+
/** Check if the queue is full
76+
*
77+
* @return True if the queue is full, false if not
78+
*/
79+
bool full() const {
80+
return osMessageQueueGetSpace(_id) == 0;
81+
}
82+
6783
/** Put a message in a Queue.
6884
@param data message pointer.
6985
@param millisec timeout value or 0 in case of no time-out. (default: 0)

0 commit comments

Comments
 (0)