/// Atomically swaps data at `dst` with `val`.
///
/// This operation uses the `AcqRel` ordering. If possible, an atomic instructions is used, and a
/// global lock otherwise.
Atomically swaps data at `dst` with `val`.
This operation uses the `AcqRel` ordering. If possible, an atomic instructions is used, and a
global lock otherwise.
Atomically swaps data at ` dst ` with ` val ` . This operation uses the ` AcqRel ` ordering . If possible an atomic instructions is used and a global lock otherwise .
pub unsafe fn atomic_swap<T, L>(lock: &L, dst: *mut Option<T>, val: Option<T>) -> Option<T>
where
    L: FallbackLock,
{
    atomic! {
        Option<T>, a,
        {
            a = &*(dst as *const _ as *const _);
            let res = mem::transmute_copy(&a.swap(mem::transmute_copy(&val), Ordering::AcqRel));
            mem::forget(val);
            res
        },
        lock.write(|| ptr::replace(dst, val))
    }
}
pub unsafe fn atomic_swap < T , L > ( lock : & L , dst : * mut Option < T > , val : Option < T > ) -> Option < T > where L : FallbackLock , { atomic ! { Option T a { a ( dst as const as const ) let res mem transmute_copy ( a swap ( mem transmute_copy ( val ) Ordering AcqRel ) ) mem forget ( val ) res } lock write ( ptr replace ( dst val ) ) } }
Atomically swaps data at `dst` with `val`.
Atomically swaps data at ` dst ` with ` val ` .
lock
&L
dst
*mut Option<T>
val
Option<T>