Skip to main content

UndoLog

Struct UndoLog 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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).

Source

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.

Trait Implementations§

Source§

impl Default for UndoLog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PreWriteHook for UndoLog

Source§

fn before_write( &mut self, cell: StateCellId, _loc: SlotLocation, old: &FourStateValue, _new_incoming: &FourStateValue, at: SimTime, )

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V