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

Thread Pool Fix High CPU Load When Paused #1039

Merged
merged 8 commits into from
Apr 13, 2024
Merged

Conversation

COM8
Copy link
Member

@COM8 COM8 commented Apr 7, 2024

Fixes #1035.

Switched from a yield based approach to a conditional variable based approach. Now all threads paused inside a thread pool are properly paused and do not consume a lot of CPU cycles while waiting.

With this PR I'm also adding additional Thread Pool test cases. They are disabled right now since there is a bug causing them to get stuck inside the:

task_cond.wait_for(locker, std::chrono::milliseconds(max_idle_time), [this]() { return status == STOP || !tasks.empty(); });

Probably the notify is not working correctly here. This will be fixed by a follow up PR.

@COM8 COM8 added the Bug 🐛 label Apr 7, 2024
@COM8 COM8 added this to the CPR 1.11.0 milestone Apr 7, 2024
@COM8 COM8 self-assigned this Apr 7, 2024
@COM8 COM8 merged commit 481c047 into master Apr 13, 2024
80 of 105 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cpr::ThreadPool high CPU usage when Paused
1 participant