module examples.atomic_publish; struct Shared { ready: AtomicBool, value: AtomicU64, } fn publish(shared: ref, value: u64) -> void effects [atomic] { atomic.store(ref shared.value, value, relaxed); atomic.store(ref shared.ready, true, release); } fn try_read(shared: ref) -> Option effects [atomic] { if atomic.load(ref shared.ready, acquire) { // The acquire observes the release on `ready`; the earlier relaxed // store to `value` is ordered before publication. `value` remains // atomic storage, so no ordinary-memory alias exception is needed. return Some(atomic.load(ref shared.value, relaxed)); } return None; }