Draft specification, RFCs, reference registries and examples, plus the reference-implementation skeleton: build.zig, diagnostic envelope with error-code registry synced to docs, aji CLI, conformance runner with seed tests, CI and contributor docs.
26 lines
702 B
Rust
26 lines
702 B
Rust
module examples.atomic_publish;
|
|
|
|
struct Shared {
|
|
ready: AtomicBool,
|
|
value: AtomicU64,
|
|
}
|
|
|
|
fn publish(shared: ref<Shared>, value: u64) -> void
|
|
effects [atomic]
|
|
{
|
|
atomic.store(ref shared.value, value, relaxed);
|
|
atomic.store(ref shared.ready, true, release);
|
|
}
|
|
|
|
fn try_read(shared: ref<Shared>) -> Option<u64>
|
|
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;
|
|
}
|