szaszm commented on a change in pull request #746: MINIFICPP-1185 - Remove
moodycamel::concurrentqueue from threadpool
URL: https://github.com/apache/nifi-minifi-cpp/pull/746#discussion_r400048134
##########
File path: libminifi/include/utils/MinifiConcurrentQueue.h
##########
@@ -81,25 +82,38 @@ class ConcurrentQueue {
: queue_( std::move(other.queue_) ) {}
protected:
- bool tryDequeue(std::unique_lock<std::mutex>& lck, T& out) {
+ void checkLock(std::unique_lock<std::mutex>& lck) const {
if (!lck.owns_lock()) {
- throw std::logic_error("Caller of protected ConcurrentQueue::tryDequeue
should own the lock!");
+ throw std::logic_error("Caller of protected functions of ConcurrentQueue
should own the lock!");
}
+ }
+
+ bool tryDequeueImpl(std::unique_lock<std::mutex>& lck, T& out) {
+ checkLock(lck);
if (queue_.empty()) {
return false;
}
out = std::move(queue_.front());
queue_.pop_front();
return true;
}
Review comment:
I like that you used protected functions taking `std::unique_lock` to make
it an error to use the non-locking functions without a lock.
----------------------------------------------------------------
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]
With regards,
Apache Git Services