pub trait AtomicSwap: AtomicLoad + AtomicStore {
// Provided method
unsafe fn atomic_swap(
dst: *mut MaybeUninit<Self>,
val: MaybeUninit<Self>,
order: Ordering,
) -> MaybeUninit<Self> { ... }
}Expand description
Atomic swap.
This trait is sealed and cannot be implemented for types outside of atomic-maybe-uninit.
Provided Methods§
Sourceunsafe fn atomic_swap(
dst: *mut MaybeUninit<Self>,
val: MaybeUninit<Self>,
order: Ordering,
) -> MaybeUninit<Self>
unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>
Stores a value into dst, returning the previous value.
atomic_swap takes an Ordering argument which describes the memory ordering
of this operation. All ordering modes are possible. Note that using
Acquire makes the store part of this operation Relaxed, and
using Release makes the load part Relaxed.
§Safety
Behavior is undefined if any of the following conditions are violated:
dstmust be valid for both reads and writes.dstmust be aligned tosize_of::<MaybeUninit<T>>()(note that on some platforms this can be bigger thanalign_of::<MaybeUninit<T>>()).ordermust beSeqCst,AcqRel,Acquire,Release, orRelaxed.- You must adhere to the Memory model for atomic accesses. In particular, it is not allowed to mix conflicting atomic and non-atomic accesses, or atomic accesses of different sizes, without synchronization.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".