Skip to main content

Module shared_versioned_chain

Module shared_versioned_chain 

Source
Expand description

SharedVersionedChain<T> - cross-process MVCC linked list.

Each node holds (version: u64, value: T). Nodes are linked newest-first via an AtomicU32 head and per-node next offsets. A reader walking from head sees nodes in descending version order and can read_at(snapshot) to find the newest version that’s <= the snapshot.

§Layout

+-----------------------------+
| ChainHeader (64B)           |
|   - magic                   |
|   - capacity                |
|   - payload_size            |
|   - head: AtomicU32 (idx)   |
|   - free_list_head: u64     |  (counter, idx) packed
|   - live_count: u64         |
+-----------------------------+
| VersionNode[0] (64B)        |
|   - version: AtomicU64      |
|   - next:   AtomicU32       |
|   - next_free: AtomicU32    |
|   - payload: [u8; 48]       |
+-----------------------------+
| VersionNode[1] ...          |
+-----------------------------+

Same slot-allocator pattern as SharedHandleTable: ABA-free Treiber stack for the free list, atomic CAS for head updates.

Structs§

ChainHeader
SharedVersionedChain
VersionNode

Enums§

ChainError

Constants§

NIL_NODE
NODE_PAYLOAD_BYTES
VERSIONED_CHAIN_MAGIC

Functions§

versioned_chain_file_size