Skip to main content

atomic_load

Function atomic_load 

Source
pub unsafe fn atomic_load<T: AtomicType, Ordering: AcquireOrRelaxed>(
    ptr: *mut T,
    o: Ordering,
) -> T
where T::Repr: AtomicBasicOps,
Expand description

Atomic load 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_load(.., Relaxed) maps to READ_ONCE() when used for inter-thread communication.
  • atomic_load(.., Acquire) maps to smp_load_acquire().

ยงSafety

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