expression

Loom model: conditional publication

A producer writes a payload and releases a readiness flag. The consumer asserts the payload only if its acquire load observes readiness. A false result is legal; this fixture does not demand that the consumer waits or prove eventual observation. Staged Cargo test, not standalone Rust or a ByteMind exercise. Expected test outcome (not executed): PASS Common mistake: Asserting readiness must be true before joining the producer.

Formal Syntax & Structure

rust syntaxrust
loom::model(|| { /* modeled operations */ });

Working Example

Example Snippetrust
#[test]fn loom_publication_invariant() {    loom::model(|| {        use loom::{sync::{Arc, atomic::{AtomicBool, AtomicUsize, Ordering::{Relaxed, Release, Acquire}}}, thread};        let state = Arc::new((AtomicUsize::new(0), AtomicBool::new(false)));        let p = state.clone();        let t = thread::spawn(move || { p.0.store(19, Relaxed); p.1.store(true, Release); });        if state.1.load(Acquire) { assert_eq!(state.0.load(Relaxed), 19); }        t.join().unwrap();    });}
Rust Reference