Skip to main content

atomic_store

Function atomic_store 

Source
pub unsafe fn atomic_store<T: AtomicType, Ordering: ReleaseOrRelaxed>(
    ptr: *mut T,
    v: T,
    o: Ordering,
)
where T::Repr: AtomicBasicOps,
Expand description

Atomic store over raw pointers.

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

  • atomic_store(.., Relaxed) maps to WRITE_ONCE() when used for inter-thread communication.
  • atomic_load(.., Release) maps to smp_store_release().

ยง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.