Skip to main content

atomic_add_f32

Function atomic_add_f32 

Source
pub fn atomic_add_f32(ptr: &mut u32, value: f32)
Expand description

Atomically adds a float value to the f32 stored (as u32 bits) at ptr.

Uses a compare-and-swap loop to emulate float atomic add: repeatedly loads the current bits, reinterprets as f32, adds value, and attempts to CAS the result back. The pointer must hold the bit pattern of a valid f32 (initialize with 0u32 for 0.0).