Skip to content

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
@COM8 COM8 deleted the threadpool_fix_high_cpu_load branch October 13, 2024 06:16
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