1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: BUSL-1.1
//! Per-key lock state for the Calvin lock table.
//!
//! A [`LockEntry`] holds either a single exclusive holder or a set of shared
//! holders, plus a FIFO waiter queue that carries each waiter's requested
//! [`LockMode`].
use VecDeque;
use SmallVec;
use TxnId;
// ── LockMode ──────────────────────────────────────────────────────────────────
/// The mode under which a lock is held or requested.
///
/// `Shared` locks are mutually compatible (many readers); `Exclusive` locks
/// conflict with everything else.
// ── AcquireOutcome ────────────────────────────────────────────────────────────
/// Result of a lock-acquire call.
// ── LockEntry ─────────────────────────────────────────────────────────────────
/// Per-key lock state.
///
/// Invariants maintained by [`LockManager`](super::manager::LockManager):
/// - `Exclusive` entries have exactly one holder.
/// - `Shared` entries have one or more holders, all compatible.
/// - `waiters` is FIFO; each waiter carries the mode it requested so that
/// promotion on release is mode-aware.
pub