arpadboda 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_r396716663
##########
File path: libminifi/src/utils/ThreadPool.cpp
##########
@@ -64,8 +64,10 @@ void ThreadPool<T>::run_tasks(std::shared_ptr<WorkerThread>
thread) {
}
}
} else {
- std::unique_lock<std::mutex> lock(worker_queue_mutex_);
- tasks_available_.wait(lock);
+ // This means that the threadpool is running, but the ConcurrentQueue is
stopped -> shouldn't happen
+ if (running_.load()) {
+ std::this_thread::sleep_for(std::chrono::milliseconds(0));
Review comment:
Meant to sleep for 1 msec, corrected that.
In case this somehow occurs in a transient state (during startup or
shutdown), this prevent the worker threads to busy wait (dequeue fails
immediately and the workers would retry without sleep).
----------------------------------------------------------------
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