pub struct UndoLog { /* private fields */ }Expand description
ST-036: the per-thread undo/reverse log — see this module’s top doc
comment for why it is a plain, caller-owned value (like ()) rather than
a StateEngine-owned field. Implements PreWriteHook: every
commit_write(cell, new, &mut log) call appends (cell, old, at) here
before the store happens (Task 8/ST-091’s own ordering guarantee),
giving that hook its first real body.
Implementations§
Source§impl UndoLog
impl UndoLog
pub fn new() -> Self
Sourcepub fn checkpoint_marker(&self) -> RollbackMark
pub fn checkpoint_marker(&self) -> RollbackMark
ST-036: an opaque marker for the log’s current length — “current”
meaning the absolute count of entries ever appended so far (already
including any Self::fossil_collect has trimmed), so a mark taken
before a trim and a mark taken after it are still comparable on the
same absolute scale.
Sourcepub fn rollback_to(
&mut self,
engine: &mut StateEngine,
mark: RollbackMark,
) -> Result<(), RewindError>
pub fn rollback_to( &mut self, engine: &mut StateEngine, mark: RollbackMark, ) -> Result<(), RewindError>
ST-036: pops entries back to mark, replaying each popped entry’s
old value into engine via StateEngine::commit_write_no_hook
(a second, hook-free write primitive, so unwinding the log never
re-appends to the very log it’s unwinding) in reverse order — Vec:: pop naturally visits the most-recently-appended entry first, which
is what makes a cell written twice since mark end up back at its
original (not its intermediate) value.
Err(RewindError::PastFossilHorizon) — never a silent
under-rollback — when mark refers to a position at or before
entries Self::fossil_collect has already, irreversibly discarded;
the log is left completely untouched in that case (checked before any
entry is popped).
Sourcepub fn fossil_collect(&mut self, gvt: SimTime)
pub fn fossil_collect(&mut self, gvt: SimTime)
Trims every entry with at <= gvt from the front of the log
(append-only, so the front holds the oldest entries) — “at or before
gvt, never past it”: the scan stops at the first entry whose at
is strictly after gvt, so nothing newer is ever removed even if a
later entry happened to compare <= some other way.