Function atomic_cxchgweak
pub const unsafe fn atomic_cxchgweak<T: Copy, const ORD_SUCC: AtomicOrdering, const ORD_FAIL: AtomicOrdering>(_dst: *mut T, _old: T, _src: T) -> (T, bool)
Stores a value if the current value is the same as the old value,
with the returned T being the previous value and the returned bool being
whether the exchange was successful.
T must be an integer or pointer type. The comparison may spuriously fail.
Safety
-
If
Tis an integer type, this is equivalent toAtomic<T>::from_ptrfollowed byAtomic<T>::compare_exchange_weak. Refer to the documentation ofAtomic<T>::from_ptrfor safety requirements. -
If
Tis a pointer type, this is equivalent toAtomicPtr<P>::from_ptrfollowed byAtomicPtr<P>::compare_exchange_weak, wherePis the pointee type of the pointer. Refer to the documentation ofAtomicPtr<P>::from_ptrfor safety requirements.
The stabilized version of this intrinsic is available on the
atomic types via the compare_exchange_weak method.
For example, AtomicBool::compare_exchange_weak.