std-method
Atomic store: replace one value
Replace a value with a single atomic write. A release store can establish synchronization with an acquire operation observing the appropriate write. A store does not return the previous value. Expected stdout (not executed): 6 Common mistake: Using store to implement a concurrent increment by separately loading and adding one.
Formal Syntax & Structure
rust syntaxrust
value.store(new: usize, order: Ordering)Working Example
Example Snippetrust
fn main() { use std::sync::atomic::{AtomicUsize, Ordering}; let n = AtomicUsize::new(10); n.store(6, Ordering::Release); println!("{}", n.load(Ordering::Acquire));}