Skip to main content

xchg

Function xchg 

Source
pub unsafe fn xchg<T: AtomicType, Ordering: Ordering>(
    ptr: *mut T,
    new: T,
    o: Ordering,
) -> T
where T::Repr: AtomicExchangeOps,
Expand description

Atomic exchange over raw pointers.

This function provides a short-cut of Atomic::from_ptr().xchg(..), and can be used to work with C side on synchronizations.

ยงSafety

  • ptr is a valid pointer to T and aligned to align_of::<T>().
  • If there is a concurrent access from kernel (C or Rust), it has to be atomic.