Skip to main content

Module shared_once_cell

Module shared_once_cell 

Source
Expand description

SharedOnceCell<T> - cross-process init-once cell.

State machine:

  • EMPTY (0): no value; first writer to CAS to INITIALIZING wins.
  • INITIALIZING (1): a writer is filling the payload; other writers spin until state advances.
  • INITIALIZED (2): payload is stable; readers may consume.

The winner of the EMPTY -> INITIALIZING CAS performs the write and advances to INITIALIZED. Losers see INITIALIZED and read the winner’s bytes.

This is the cross-process analog of once_cell::sync::OnceCell, with cross-process safety guaranteed by the atomic CAS protocol over shared memory.

Structs§

OnceHeader
SharedOnceCell

Enums§

SharedOnceError

Constants§

ONCE_FILE_SIZE
ONCE_MAGIC
ONCE_PAYLOAD_BYTES
STATE_EMPTY
STATE_INITIALIZED
STATE_INITIALIZING