mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
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
This commit is contained in:
@@ -419,8 +419,7 @@ pub fn pin(data: T) -> Pin<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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user