atomic_maybe_uninit::raw

Trait AtomicSwap

Source
pub trait AtomicSwap: AtomicLoad + AtomicStore {
    // Required 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.

Required Methods§

Source

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:

  • dst must be valid for both reads and writes.
  • dst must be properly aligned to the size of Self. (For example, if Self is u128, dst must be aligned to 16-byte even if the alignment of u128 is 8-byte.)
  • order must be SeqCst, AcqRel, Acquire, Release, or Relaxed.

The rules for the validity of the pointer follow the rules applied to functions exposed by the standard library’s ptr module, except that concurrent atomic operations on dst are allowed if the pointer go through UnsafeCell::get.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AtomicSwap for i8

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for i16

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for i32

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for i64

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for isize

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for u8

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for u16

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for u32

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for u64

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Source§

impl AtomicSwap for usize

Source§

unsafe fn atomic_swap( dst: *mut MaybeUninit<Self>, val: MaybeUninit<Self>, order: Ordering, ) -> MaybeUninit<Self>

Implementors§