Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,12 @@ struct ArcInner<T: ?Sized> {
strong: Atomic<usize>,

// the value usize::MAX acts as a sentinel for temporarily "locking" the
// ability to upgrade weak pointers or downgrade strong ones; this is used
// to avoid races in `make_mut` and `get_mut`.
// weak count, preventing `Arc::downgrade` from racing to create new
// `Weak` references. `Arc::is_unique` (which backs `Arc::get_mut`)
// needs to observe both the strong and weak counts as indicating
// uniqueness in one logical atomic step; since they live in separate
// atomic words, it locks the weak count while reading the strong
// count to keep the two reads consistent.
weak: Atomic<usize>,

data: T,
Expand Down
Loading