Skip to content

Commit aef2ca6

Browse files
authored
Rollup merge of #74025 - tmiasko:try-unwrap, r=Amanieu
Remove unnecessary release from Arc::try_unwrap The thread that recovers the unique access to Arc inner value (e.g., drop when ref-count strong reaches zero, successful try_unwrap), ensures that other operations on Arc inner value happened before by synchronizing with release operations performed when decrementing the reference counter. When try_unwrap succeeds, the current thread recovers the unique access to Arc inner value, so release is unnecessary. r? @Amanieu
2 parents 0eadeda + 8900502 commit aef2ca6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/liballoc/sync.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ impl<T> Arc<T> {
419419
#[inline]
420420
#[stable(feature = "arc_unique", since = "1.4.0")]
421421
pub fn try_unwrap(this: Self) -> Result<T, Self> {
422-
// See `drop` for why all these atomics are like this
423-
if this.inner().strong.compare_exchange(1, 0, Release, Relaxed).is_err() {
422+
if this.inner().strong.compare_exchange(1, 0, Relaxed, Relaxed).is_err() {
424423
return Err(this);
425424
}
426425

0 commit comments

Comments
 (0)