changeset 2078:93afa6134ab3

SharedMessageQueue::Clear
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 01 Sep 2016 16:54:35 +0200
parents 14ce887a9182
children bb93de4f4562
files Core/MultiThreading/SharedMessageQueue.cpp Core/MultiThreading/SharedMessageQueue.h
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Core/MultiThreading/SharedMessageQueue.cpp	Wed Aug 31 17:35:38 2016 +0200
+++ b/Core/MultiThreading/SharedMessageQueue.cpp	Thu Sep 01 16:54:35 2016 +0200
@@ -185,4 +185,24 @@
     boost::mutex::scoped_lock lock(mutex_);
     isFifo_ = false;
   }
+
+  void SharedMessageQueue::Clear()
+  {
+    boost::mutex::scoped_lock lock(mutex_);
+
+    if (queue_.empty())
+    {
+      return;
+    }
+    else
+    {
+      while (!queue_.empty())
+      {
+        std::auto_ptr<IDynamicObject> message(queue_.front());
+        queue_.pop_front();
+      }
+
+      emptied_.notify_all();
+    }
+  }
 }
--- a/Core/MultiThreading/SharedMessageQueue.h	Wed Aug 31 17:35:38 2016 +0200
+++ b/Core/MultiThreading/SharedMessageQueue.h	Thu Sep 01 16:54:35 2016 +0200
@@ -78,5 +78,7 @@
     void SetFifoPolicy();
 
     void SetLifoPolicy();
+
+    void Clear();
   };
 }