Enter your book access code

The curriculum, drills, tutor, and interviewer mode are for readers of Ace the Rust Interview. The code is printed in the Preface (Companion site access).

Don’t have the book yet? The landing page stays open — purchase unlocks this gym.

advanced · order 176

Relaxed vs Acquire/Release

conc-atomic-01Related book chapters: 12 (optional — this page is complete on its own)atomicsOrdering

Slug: conc-atomic-01 · Paired reading: Chapter 12

Prompt

fn bump_relaxed(n: usize) -> usizeAtomicUsize counter with Ordering::Relaxed fetch_add from several threads (counter only). fn publish(flag: &AtomicBool, data: &mut i32) — write data, then store(true, Release). fn observe(...) -> Option<i32>load(Acquire) then read data if flag set. Demonstrate the pairing.