about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-05 16:07:32 -0700
committerGitHub <noreply@github.com>2020-07-05 16:07:32 -0700
commitaef2ca6681cb2d5fb9ae613df8e94ad906c05085 (patch)
tree11eba59c14a893f5ef4da0dd779b5b1df106eec5 /src/liballoc
parent0eadeda94509ef8e15af539fb3ae771aa84c98ad (diff)
parent8900502a887d98a8f5a6b8774f1c756e89d4c29f (diff)
downloadrust-aef2ca6681cb2d5fb9ae613df8e94ad906c05085.tar.gz
rust-aef2ca6681cb2d5fb9ae613df8e94ad906c05085.zip
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
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/sync.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs
index ac3ce2255c8..2d6a3917c76 100644
--- a/src/liballoc/sync.rs
+++ b/src/liballoc/sync.rs
@@ -419,8 +419,7 @@ impl<T> Arc<T> {
     #[inline]
     #[stable(feature = "arc_unique", since = "1.4.0")]
     pub fn try_unwrap(this: Self) -> Result<T, Self> {
-        // See `drop` for why all these atomics are like this
-        if this.inner().strong.compare_exchange(1, 0, Release, Relaxed).is_err() {
+        if this.inner().strong.compare_exchange(1, 0, Relaxed, Relaxed).is_err() {
             return Err(this);
         }