Files
sx/examples/atomics/1700-atomics-load-store.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +03:00

18 lines
633 B
Plaintext

// Atomic($T) load/store with explicit memory orderings, single-thread.
// Stream A (atomics) A.0 + A.0.5 — the ordering is a comptime `$o: Ordering`
// param (explicit, Rust-style): a.load(.acquire) emits `load atomic … acquire`.
// An invalid combination (a.load(.release)) is a compile error (see 1131).
#import "modules/std.sx";
#import "modules/std/atomic.sx";
main :: () {
a := Atomic(i64).init(7);
print("init: {}\n", a.load(.seq_cst));
a.store(42, .release);
print("after store: {}\n", a.load(.acquire));
a.store(a.load(.relaxed) + 1, .seq_cst);
print("incremented: {}\n", a.load(.seq_cst));
}