std-type

AtomicBool: shared flag

An atomic boolean supports atomic access to a flag. A flag can indicate a state change, but publishing other data requires a justified synchronization protocol. Expected stdout (not executed): true Common mistake: Using a relaxed flag alone to publish unrelated data.

Formal Syntax & Structure

rust syntaxrust
AtomicBool::new(value: bool)

Working Example

Example Snippetrust
fn main() {    use std::sync::atomic::{AtomicBool, Ordering};    let ready = AtomicBool::new(false);    ready.store(true, Ordering::Relaxed);    println!("{}", ready.load(Ordering::Relaxed));}
Rust Reference