bakaid 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_r396538818
########## File path: libminifi/include/utils/ThreadPool.h ########## @@ -303,8 +303,9 @@ class ThreadPool { * Drain will notify tasks to stop following notification */ void drain() { + worker_queue_.stop(); while (current_workers_ > 0) { - tasks_available_.notify_one(); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); Review comment: In my understanding, it is to wait for all worker thread functions to return. They are either in a task or waiting for one. If they are waiting for one, worker_queue_.stop() will make the tryDeqeue return with false and they will end. If they are in a task, they will finish executing it, call tryDeqeue, which will return false, and they will end. My initial reaction at first was "why are we not using the ConcurrentQueue's cv instead of "<<polling>>" but I realized that is more complex than that. ---------------------------------------------------------------- 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 With regards, Apache Git Services