Bug: paused pool does a hidden busy loop
guilhermelawless opened this issue · 1 comments
guilhermelawless commented
Once a pool is paused and a task received, the worker wait is skipped it repeats the loop until unpaused. This makes workers enter a busy loop with max CPU usage.
Did not find a way to test for this in the testing code.
Fix:
- Change the worker wait condition to
task_available_cv.wait(tasks_lock, [this] { return (!tasks.empty() && !paused) || !workers_running; });
- Add
task_available_cv.notify_all();
inunpause()
bshoshany commented
Thanks for the bug report! This somehow slipped through the cracks. I don't think there's any way to automate this test, since the C++ standard library does not allow you to check CPU utilization of a thread, but I did a quick test and I can confirm that this bug exists and that your fix resolves it.
The fix will be implemented in release v3.6.0, which should hopefully be available within a few weeks (even sooner if I can find the time). Thanks again :)