Skip to main content

Module seqlock

Module seqlock 

Source
Expand description

This module provides seqlock-based atomic pairs for the atomic multi-threading method. Seqlock-based atomic pairs for the atomic multi-threading method.

AtomicU128 is unstable on stable Rust, and two separate AtomicU64s allow torn (x, y) reads. A seqlock — a version counter plus two bit-pattern AtomicU64s — gives torn-free whole-pair reads without 128-bit atomics.

Each slot is single-writer, multi-reader: the owning thread calls store while every other thread only calls load. The writer bumps the sequence to odd while updating, then to even when stable; readers retry until they observe a stable (even) sequence with matching reads of both components.

Structs§

AtomicComplex
Atomic Complex<f64> (seqlock over re/im) — whole-pair atomicity.
AtomicF64x2
Seqlock over a pair of f64 values (single-writer, multi-reader).
AtomicVec2
Atomic Vector2<f64> (seqlock over x/y) — whole-pair atomicity.