Skip to main content

Module shared_rw_lock

Module shared_rw_lock 

Source
Expand description

SharedRWLock - cross-process reader-writer lock with writer priority.

Multiple concurrent readers OR exactly one writer. When a writer is waiting, new readers block to prevent writer starvation.

§State encoding

ONE AtomicU64 packed:

  • bit 63: writer active (1 if a writer holds the lock)
  • bits 32-62: writers waiting count (31 bits)
  • bits 0-31: reader count (32 bits)

All transitions are single CAS so observers never see torn state.

Structs§

RWLockHeader
ReadGuard
SharedRWLock
WriteGuard

Enums§

RWLockError

Constants§

RWLOCK_MAGIC