Module lock

Module lock 

Source
Expand description

Lock typestate for compile-time safety of lock lifecycle.

Uses the typestate pattern to make invalid state transitions uncompilable. A lock can only be released or extended when it’s in the Acquired state.

§State Transition Diagram

(unlocked) ─── acquire() ──→ Acquired ─── release() ──→ (unlocked)
                                 │
                            extend() ↺

Modules§

private 🔒

Structs§

Acquired
Lock is currently held (acquired).
Lock
A lock with compile-time state tracking.
LockRecord
Internal data storage for a lock, independent of typestate. This is what gets persisted to the database.
Released
Lock has been released (for documentation; locks in this state don’t exist at runtime).
StoredLock
A lock as stored in the database (status-agnostic).

Enums§

LockMode
Lock mode determining concurrency behavior.
LockStateError
Errors when transitioning lock states.

Traits§

LockState
Marker trait for lock states.

Functions§

compute_lock_key
Compute a stable i64 key for advisory locks using FNV-1a hash.