Skip to main content

Module shared_linked_list

Module shared_linked_list 

Source
Expand description

SharedLinkedList<T> - cross-process doubly-linked list with O(1) handle-based removal.

Backed by SharedRegion of Node<T>. Each node stores T plus raw next and prev slot indices. Slot 0 is the sentinel head; real nodes live in slots 1..N.

§Architectural value: stable handles

Push operations return a NodeHandle - a stable u32 slot index. Callers retain handles to call remove(handle) for O(1) middle removal. This is the unique value over SharedRing (FIFO only, no random access) and SharedVec (no middle removal).

§Handle validity contract

A NodeHandle is valid from the moment push returns it until the caller invokes remove(handle) or one of the pop operations on that node. Using a stale handle after the node has been removed is a logic error (the slot may have been reused by a subsequent push). This is the same contract as std::list::iterator in C++.

§Concurrency model

SINGLE-WRITER, MULTI-READER. push / pop / remove / set require external serialisation (wrap in a SharedSemaphore with 1 permit, or use the application’s own coordination). Iteration is lock-free.

Structs§

Node
NodeHandle
Stable handle to a list node. Valid until removed.
SharedLinkedList

Enums§

LinkedListError

Constants§

HEAD_INDEX
Slot index of the sentinel head node within the underlying SharedRegion. Always 0; allocated at create time.
NIL_INDEX
Sentinel NIL value for next/prev pointers.