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

Potential zero threads #51

Closed
TLCFEM opened this issue Jun 12, 2022 · 1 comment
Closed

Potential zero threads #51

TLCFEM opened this issue Jun 12, 2022 · 1 comment

Comments

@TLCFEM
Copy link

TLCFEM commented Jun 12, 2022

explicit thread_pool(const concurrency_t thread_count_ = std::thread::hardware_concurrency()) : thread_count(thread_count_ ? thread_count_ : std::thread::hardware_concurrency()), threads(std::make_unique<std::thread[]>(thread_count_ ? thread_count_ : std::thread::hardware_concurrency()))

std::thread::hardware_concurrency() may return 0. So when constructed as thread_pool(), thread_count may be initialised to 0. thread_count(thread_count_ > 1 ? thread_count_ : 1 may be safer.

@bshoshany
Copy link
Owner

Thanks, I will fix this in the next release.

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