We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 83c659e commit 49edaf1Copy full SHA for 49edaf1
src/liballoc/arc.rs
@@ -453,7 +453,10 @@ impl<T: ?Sized> Arc<T> {
453
#[inline]
454
#[stable(feature = "arc_counts", since = "1.15.0")]
455
pub fn weak_count(this: &Self) -> usize {
456
- this.inner().weak.load(SeqCst) - 1
+ let cnt = this.inner().weak.load(SeqCst);
457
+ // If the weak count is currently locked, the value of the
458
+ // count was 0 just before taking the lock.
459
+ if cnt == usize::MAX { 0 } else { cnt - 1 }
460
}
461
462
/// Gets the number of strong (`Arc`) pointers to this value.
0 commit comments