dam4rus commented on a change in pull request #992:
URL: https://github.com/apache/nifi-minifi-cpp/pull/992#discussion_r579212323



##########
File path: libminifi/include/utils/MinifiConcurrentQueue.h
##########
@@ -135,6 +143,22 @@ class ConcurrentQueue {
   std::deque<T> queue_;
 };
 
+// Enables batched operations on a ConcurrentQueue by holding a reference to 
the queue and locking it's mutex
+// until it leaves the scope. Can help performance by avoiding multiple 
locking in loops, etc.
+template <typename T>
+class LockedConcurrentQueue {
+ public:
+  explicit LockedConcurrentQueue(ConcurrentQueue<T>& concurrentQueue)
+      : queue_(std::ref(concurrentQueue.queue_))
+      , lock_(concurrentQueue.mtx_) {
+  }
+
+  std::deque<T>* operator->() const { return &queue_.get(); }

Review comment:
       It has already been discussed and if everyone agrees with this approach 
I'm totally fine with providing a public API instead of overloaded operators.




----------------------------------------------------------------
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:
[email protected]


Reply via email to