Conversation
|
|
||
| /// Return the number of threads that we are using for the frontend. | ||
| /// Returns `None` if synchronization is not required. | ||
| pub fn parallel_thread_count(&self) -> Option<NonZero<usize>> { |
Contributor
There was a problem hiding this comment.
So much boilerplate and we still convert the "newtypes" back to an option in most places.
This is exactly what I wanted to avoid originally.
Member
Author
There was a problem hiding this comment.
The actual representation is an Option<NonZero<usize>>, but I think that there is benefit to wrapping it, so that we make it easier to understand how exactly it behaves.
What about a compromise:
struct FrontendJobs(Option<NonZero<usize>>);This allows us to document the behavior + add methods to the type to reduce confusion of how it behaves, vs just using is_none().
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found the
Option<NonZero<usize>>representation quite confusing. This PR replaces it with strongly typed enums, which helps with creating specialized methods (is_synchronized), and documenting what do the individual variants mean, rather than just working withSome/Noneand callingis_some().Otherwise, the behavior should be unchanged.
I think that the
MaybeParallelvariant could also be namedSynchronized, but there is no perfect solution here to really express what it means.r? petrochenkov