nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #773: MINIFICPP-1202 - Extend interface and add new tests for MinifiConcurrentQueue
Date Mon, 04 May 2020 12:44:55 GMT

hunyadi-dev commented on a change in pull request #773:
URL: https://github.com/apache/nifi-minifi-cpp/pull/773#discussion_r419407398



##########
File path: libminifi/include/utils/MinifiConcurrentQueue.h
##########
@@ -127,33 +184,58 @@ class ConditionConcurrentQueue : private ConcurrentQueue<T> {
   using ConcurrentQueue<T>::empty;
   using ConcurrentQueue<T>::clear;
 
-
   template <typename... Args>
   void enqueue(Args&&... args) {
     ConcurrentQueue<T>::enqueue(std::forward<Args>(args)...);
     if (running_) {
       cv_.notify_one();
     }
   }
-  
+
   bool dequeueWait(T& out) {
     std::unique_lock<std::mutex> lck(this->mtx_);
-    cv_.wait(lck, [this, &lck]{ return !running_ || !this->emptyImpl(lck); });  //
Only wake up if there is something to return or stopped 
-    return running_ && ConcurrentQueue<T>::tryDequeueImpl(lck, out);
+    if (!running_) {
+      return false;
+    }
+    cv_.wait(lck, [this, &lck]{ return !running_ || !this->emptyImpl(lck); });  //
Only wake up if there is something to return or stopped
+    return ConcurrentQueue<T>::tryDequeueImpl(lck, out);
+  }
+
+  template<typename Functor>
+  bool consumeWait(Functor&& fun) {
+    std::unique_lock<std::mutex> lck(this->mtx_);
+    if (!running_) {

Review comment:
       Removed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message