pub struct ExecutionTimer { /* private fields */ }Expand description
Cooperative time-limit tracker shared across interpreter and VM loops.
Implementations§
Source§impl ExecutionTimer
impl ExecutionTimer
Sourcepub const fn new(config: Option<ExecutionTimerConfig>) -> Self
pub const fn new(config: Option<ExecutionTimerConfig>) -> Self
Construct a new timer with the provided configuration.
Sourcepub const fn reset(&mut self)
pub const fn reset(&mut self)
Reset the timer state to its initial configuration without recording a start instant.
Sourcepub const fn start(&mut self, now: Duration)
pub const fn start(&mut self, now: Duration)
Reset any prior state and record the start instant.
Sourcepub const fn config(&self) -> Option<ExecutionTimerConfig>
pub const fn config(&self) -> Option<ExecutionTimerConfig>
Returns the timer configuration.
Sourcepub const fn last_elapsed(&self) -> Duration
pub const fn last_elapsed(&self) -> Duration
Returns the last elapsed duration recorded by a check.
Sourcepub fn tick(&mut self, work_units: u32, now: Duration) -> Result<(), LimitError>
pub fn tick(&mut self, work_units: u32, now: Duration) -> Result<(), LimitError>
Increment work units and run the periodic limit check when necessary.
Sourcepub fn check_now(&mut self, now: Duration) -> Result<(), LimitError>
pub fn check_now(&mut self, now: Duration) -> Result<(), LimitError>
Force an immediate check against the configured deadline.
Sourcepub fn elapsed(&self, now: Duration) -> Option<Duration>
pub fn elapsed(&self, now: Duration) -> Option<Duration>
Compute elapsed time relative to the recorded start, if available.
Sourcepub const fn resume_from_elapsed(&mut self, now: Duration, elapsed: Duration)
pub const fn resume_from_elapsed(&mut self, now: Duration, elapsed: Duration)
Realign the timer start so that a previously consumed elapsed duration is preserved while
ignoring any wall-clock time that passed during a suspension window.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExecutionTimer
impl RefUnwindSafe for ExecutionTimer
impl Send for ExecutionTimer
impl Sync for ExecutionTimer
impl Unpin for ExecutionTimer
impl UnwindSafe for ExecutionTimer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more