pub struct LockState { /* private fields */ }Expand description
The aggregate lock state of a single file, shared by every open handle to it.
This encodes SQLite’s lock-compatibility rules (os.c / pager.c): many
SHARED readers may coexist; a single RESERVED write-intent lock coexists
with readers; PENDING stops new readers while a writer drains the
existing ones; and EXCLUSIVE excludes everything else. A VFS shares one
LockState per path among its handles so concurrent connections in the same
process serialize exactly as separate SQLite connections would.
Implementations§
Source§impl LockState
impl LockState
Sourcepub fn acquire(&mut self, from: LockLevel, to: LockLevel) -> Result<()>
pub fn acquire(&mut self, from: LockLevel, to: LockLevel) -> Result<()>
Move a handle from lock level from up to to, mutating the shared
state. Returns Error::Busy if another handle holds an incompatible
lock. A request at or below the current level is a no-op success.
Sourcepub fn has_write_intent(&self) -> bool
pub fn has_write_intent(&self) -> bool
Whether any write-intent lock (RESERVED/PENDING/EXCLUSIVE) is held by
some handle in this process. Used by the std VFS to decide when the
process must hold an OS-level exclusive lock (ROADMAP C9b).
Sourcepub fn reader_count(&self) -> usize
pub fn reader_count(&self) -> usize
Number of SHARED (read) locks currently held across all handles.