Align RwLockWriteGuard
fields with the other RwLock
guards (+ cleanup)
#140018
+298
−256
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.
Tracking Issue: #138559
Relevant comment: #138559 (comment)
Summary
This PR does a few things as setup for the implementation of
try_upgrade
onRwLock
. They are mostly cosmetic changes.'rwlock
instead of using'a
poison
fields topoison_guard
(if this change makes sense, we should also rename thepoison
field inMutexGuard
)RwLockWriteGuard
to be similar to the other 3 guardsChanges
The only non-cosmetic change here is the last point, in which the fields of
RwLockWriteGuard
are different.As a TLDR for #138559 (comment), if we want to convert a
RwLockReadGuard
into aRwLockWriteGuard
safely (as we will need to fortry_upgrade
), I'm pretty sure we need to make the fields the same otherwise we have to do some nasty transmuting. Note it is very possible that I could be wrong on this.Concerns
I do have a concern over the
noalias
comment that I essentially copied and pasted from the docs forMappedRwLockWriteGuard
. Is it really true that making the data fieldNonNull
here avoidsnoalias
LLVM violations in the exclusive / unique setting? This description makes sense for the read variants of the guards, but I'm having trouble wrapping my head around the logic for the write variants.I am also somewhat concerned because
MutexGuard
only stores a reference whileMappedMutexGuard
stores a pointer.The only reason I have it here is because
MappedRwLockWriteGuard
was merged in #117107. CC'ing @zachs18 since he wrote that PR.