diff options
| author | Alex Saveau <saveau.alexandre@gmail.com> | 2023-09-04 21:43:21 +0100 |
|---|---|---|
| committer | Alex Saveau <saveau.alexandre@gmail.com> | 2023-09-04 21:48:51 +0100 |
| commit | 4c2f1c615b976fcd21f6cc2078b09d10c9d72507 (patch) | |
| tree | 55215991e718561057f66f975da1b28d46ed166f | |
| parent | ec08a0337f3556212525dbf1d3b41e19bdf27621 (diff) | |
| download | rust-4c2f1c615b976fcd21f6cc2078b09d10c9d72507.tar.gz rust-4c2f1c615b976fcd21f6cc2078b09d10c9d72507.zip | |
Weaken needlessly restrictive orderings on Arc::*_count
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
| -rw-r--r-- | library/alloc/src/sync.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index d3b7558440c..fd313a58e27 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -1616,7 +1616,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> { #[must_use] #[stable(feature = "arc_counts", since = "1.15.0")] pub fn weak_count(this: &Self) -> usize { - let cnt = this.inner().weak.load(Acquire); + let cnt = this.inner().weak.load(Relaxed); // If the weak count is currently locked, the value of the // count was 0 just before taking the lock. if cnt == usize::MAX { 0 } else { cnt - 1 } @@ -1646,7 +1646,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> { #[must_use] #[stable(feature = "arc_counts", since = "1.15.0")] pub fn strong_count(this: &Self) -> usize { - this.inner().strong.load(Acquire) + this.inner().strong.load(Relaxed) } /// Increments the strong reference count on the `Arc<T>` associated with the @@ -2801,7 +2801,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> { #[must_use] #[stable(feature = "weak_counts", since = "1.41.0")] pub fn strong_count(&self) -> usize { - if let Some(inner) = self.inner() { inner.strong.load(Acquire) } else { 0 } + if let Some(inner) = self.inner() { inner.strong.load(Relaxed) } else { 0 } } /// Gets an approximation of the number of `Weak` pointers pointing to this @@ -2820,7 +2820,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> { pub fn weak_count(&self) -> usize { if let Some(inner) = self.inner() { let weak = inner.weak.load(Acquire); - let strong = inner.strong.load(Acquire); + let strong = inner.strong.load(Relaxed); if strong == 0 { 0 } else { |
