Android/Linux/rdrand: Use once_cell::race::OnceBool instead of LazyBool. #483
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.
Remove src/lazy.rs.
lazy::LazyBool
had "last to win the race" semantics. When multiple threads see an uninitializedLazyBool
, all of them will calculate a value. As they finish, each one will overwrite the value set by the thread that finished previously. If two threads calculate different values for the boolean, then the value of the boolean can change during the period where the threads are racing. This doesn't seem to be a huge issue with the way it is currently used, but it is hard to reason about.once_cell::race::OnceBool
has "first to win the race" semantics. When multiple threads see an uninitializedOnceBool
, all of them will calculate a value. The first one to finish will write its value; the rest will have their work ignored. Thus there is never any change in the stored value at any point. This is much easier to reason about.The different semantics come down to the fact that once_cell uses
AtomicUsize::compare_exchange
whereas lazy.rs was usingAtomicUsize::store
.