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:
commit
aef2ca6681
1 changed files with 1 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue