-
Notifications
You must be signed in to change notification settings - Fork 1.7k
refactor: add get_available_parallelism function
#13595
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
Conversation
comphead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @alan910127 for your first contribution.
Please take care on clippy. I feel the PR is good.
|
@alan910127 please rebase from the latest main |
|
@comphead Rebased. |
comphead
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks @alan910127
|
Since this is a first time contribution I'll be waiting for another review before merging it in |
jonahgao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @alan910127 . I merged main, so that this PR can be checked by the new version of clippy.
Which issue does this PR close?
Closes #13591.
Rationale for this change
In #13579 (review), it was suggested that the repeated use of
std::thread::available_parallelismwith fallback logic could be refactored for clarity and to reduce duplication. Extracting this logic into a utility function improves code readability and reduces the likelihood of errors.What changes are included in this PR?
This PR introduces a new utility function:
It replaces the following repeated code snippet:
with a call to the new function:
Are these changes tested?
No tests are added for this change as it is a straightforward refactor of existing functionality. However, if reviewers feel this requires testing, I am happy to add them.
Are there any user-facing changes?
No.