Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: paused pool does a hidden busy loop #120

Closed
guilhermelawless opened this issue Oct 23, 2023 · 1 comment
Closed

Bug: paused pool does a hidden busy loop #120

guilhermelawless opened this issue Oct 23, 2023 · 1 comment

Comments

@guilhermelawless
Copy link

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(); in unpause()
@bshoshany
Copy link
Owner

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants