pub const unsafe fn atomic_cxchg<T: Copy, const ORD_SUCC: AtomicOrdering, const ORD_FAIL: AtomicOrdering>(
dst: *mut T,
old: T,
src: T,
) -> (T, bool)core_intrinsics)Expand description
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.
§Safety
-
If
Tis an integer type, this is equivalent toAtomic<T>::from_ptrfollowed byAtomic<T>::compare_exchange. 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, 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 method.
For example, AtomicBool::compare_exchange.