Fix deprecation warning (#457)

This commit is contained in:
Alice Ryhl
2020-12-29 22:46:39 +01:00
committed by GitHub
parent 064ad9a1a0
commit ed71a7beb3
+10 -8
View File
@@ -1023,24 +1023,24 @@ unsafe fn shallow_clone_vec(
// `Release` is used synchronize with other threads that // `Release` is used synchronize with other threads that
// will load the `arc` field. // will load the `arc` field.
// //
// If the `compare_and_swap` fails, then the thread lost the // If the `compare_exchange` fails, then the thread lost the
// race to promote the buffer to shared. The `Acquire` // race to promote the buffer to shared. The `Acquire`
// ordering will synchronize with the `compare_and_swap` // ordering will synchronize with the `compare_exchange`
// that happened in the other thread and the `Shared` // that happened in the other thread and the `Shared`
// pointed to by `actual` will be visible. // pointed to by `actual` will be visible.
let actual = atom.compare_and_swap(ptr as _, shared as _, Ordering::AcqRel); match atom.compare_exchange(ptr as _, shared as _, Ordering::AcqRel, Ordering::Acquire) {
Ok(actual) => {
if actual as usize == ptr as usize { debug_assert!(actual as usize == ptr as usize);
// The upgrade was successful, the new handle can be // The upgrade was successful, the new handle can be
// returned. // returned.
return Bytes { Bytes {
ptr: offset, ptr: offset,
len, len,
data: AtomicPtr::new(shared as _), data: AtomicPtr::new(shared as _),
vtable: &SHARED_VTABLE, vtable: &SHARED_VTABLE,
};
} }
}
Err(actual) => {
// The upgrade failed, a concurrent clone happened. Release // The upgrade failed, a concurrent clone happened. Release
// the allocation that was made in this thread, it will not // the allocation that was made in this thread, it will not
// be needed. // be needed.
@@ -1051,6 +1051,8 @@ unsafe fn shallow_clone_vec(
// count. // count.
shallow_clone_arc(actual as _, offset, len) shallow_clone_arc(actual as _, offset, len)
} }
}
}
unsafe fn release_shared(ptr: *mut Shared) { unsafe fn release_shared(ptr: *mut Shared) {
// `Shared` storage... follow the drop steps from Arc. // `Shared` storage... follow the drop steps from Arc.