hunyadi-dev commented on a change in pull request #773: URL: https://github.com/apache/nifi-minifi-cpp/pull/773#discussion_r419378919
########## 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: I felt like refraining from waiting on the lock if the queue is stopped. This is redundant though and will be 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: us...@infra.apache.org