AtomicList
AtomicList is an experimental circular list built directly from intrusive,
reference-counted nodes. The crate ships nodes and cursors only—there is no
separate list container—so you keep a Node<T> (and optionally a shared
cursor::Cursor) as your handle into the ring. A sync::Node<T> acts like a
tiny Arc<T> that also stores strong and weak successors, letting CAS
loops splice nodes in and out of a ring without locks or external hazard-pointer
schemes.
Current surface area
Node<T>/WeakNode<T>: Arc/Weak-like handles with embedded successor edges.- Lock-free splice helpers:
push_before,pop_when, andremove_selfrearrange a ring while maintaining the self-loop invariants on detached nodes. - Successor introspection:
load_next_*plusfind_next_strongfollow weak breadcrumbs after a node has been popped out. - Shared traversal:
cursor::Cursoris an atomic cursor that multiple holders advance together. - Reusable atomics:
atm_pexports generic atomic pointer wrappers used by the list but also usable forArc/Weak.
Working with nodes
use Node;
let root = new;
root.push_before.unwrap;
root.push_before.unwrap;
// Remove the first node whose payload ends with "1".
let removed = root.pop_when.unwrap;
assert_eq!;
// The ring closes back over the gap.
assert_eq!;
assert!;
// Detached nodes keep a weak breadcrumb into the live ring.
assert_eq!;
assert_eq!;
Coordinated traversal
use ;
let head = new;
for i in 1..=3
// Multiple holders share the same atomic cursor position.
let mut cursor_a = new;
let mut cursor_b = cursor_a.clone;
assert_eq!;
assert_eq!;
// Advancing from either handle moves everyone forward.
assert_eq!;
assert_eq!;
Notes
- Pure atomics: no hazard pointers or epoch GC, just ref-counted nodes.
- There is no separate
AtomicListstruct; hang on to aNode<T>as your entry point into the ring. - The API is experimental and may still shift as iteration ergonomics improve.
License
This project is distributed under the terms of the MIT license. See LICENSE for details.