diff options
Diffstat (limited to 'libtiutils')
-rwxr-xr-x | libtiutils/MessageQueue.cpp | 18 | ||||
-rwxr-xr-x | libtiutils/MessageQueue.h | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libtiutils/MessageQueue.cpp b/libtiutils/MessageQueue.cpp index 28bb0e3..11f5407 100755 --- a/libtiutils/MessageQueue.cpp +++ b/libtiutils/MessageQueue.cpp @@ -276,6 +276,24 @@ bool MessageQueue::isEmpty() return !mHasMsg; } +void MessageQueue::clear() +{ + if(!this->fd_read) + { + MSGQ_LOGEA("read descriptor not initialized for message queue"); + LOG_FUNCTION_NAME_EXIT; + return; + } + + Message msg; + while(!isEmpty()) + { + get(&msg); + } + +} + + /** @brief Force whether the message queue has message or not diff --git a/libtiutils/MessageQueue.h b/libtiutils/MessageQueue.h index 97e11a7..6d05201 100755 --- a/libtiutils/MessageQueue.h +++ b/libtiutils/MessageQueue.h @@ -83,6 +83,8 @@ public: ///Returns if the message queue is empty or not bool isEmpty(); + void clear(); + ///Force whether the message queue has message or not void setMsg(bool hasMsg=false); |