[Libreoffice-commits] online.git: loolwsd/MessageQueue.cpp loolwsd/MessageQueue.hpp

Henry Castro hcastro at collabora.com
Wed Dec 23 09:10:07 PST 2015


 loolwsd/MessageQueue.cpp |    6 ++++++
 loolwsd/MessageQueue.hpp |    3 +++
 2 files changed, 9 insertions(+)

New commits:
commit e0241b1825e1cc186b489030ed012abed35d17b5
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Dec 13 23:36:46 2015 -0500

    loolwsd: Added remove_if to MessageQueue
    
    Change-Id: If4e72796eb39ee66e7604cf67688329fc94d9539
    Reviewed-on: https://gerrit.libreoffice.org/20900
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/MessageQueue.cpp b/loolwsd/MessageQueue.cpp
index 8e28585..a4e01cf 100644
--- a/loolwsd/MessageQueue.cpp
+++ b/loolwsd/MessageQueue.cpp
@@ -37,6 +37,12 @@ void MessageQueue::clear()
     clear_impl();
 }
 
+void MessageQueue::remove_if(std::function<bool(const std::string&)> pred)
+{
+    std::unique_lock<std::mutex> lock(_mutex);
+    std::remove_if(_queue.begin(), _queue.end(), pred);
+}
+
 void MessageQueue::put_impl(const std::string& value)
 {
     _queue.push_back(value);
diff --git a/loolwsd/MessageQueue.hpp b/loolwsd/MessageQueue.hpp
index 26a1d51..4b9149e 100644
--- a/loolwsd/MessageQueue.hpp
+++ b/loolwsd/MessageQueue.hpp
@@ -38,6 +38,9 @@ public:
     /// Thread safe removal of all the pending messages.
     void clear();
 
+    /// Thread safe remove_if.
+    void remove_if(std::function<bool(const std::string&)> pred);
+
 private:
     std::mutex _mutex;
     std::condition_variable _cv;


More information about the Libreoffice-commits mailing list