pub struct ManualScheduler { /* private fields */ }Expand description
A clock that only moves when told to, like fake timers in JS tests.
Timers run in order of due time, then of creation; a repeating timer
keeps its place among timers due at the same time (setInterval keeps
its timer ID).
Implementations§
Source§impl ManualScheduler
impl ManualScheduler
Sourcepub fn run_checkpoints(&self)
pub fn run_checkpoints(&self)
Runs the pending checkpoints, as JS runs microtasks before a timer.
Sourcepub fn pending_timers(&self) -> usize
pub fn pending_timers(&self) -> usize
The number of timers that have not fired or been cancelled.
Sourcepub fn advance(&self, ms: f64)
pub fn advance(&self, ms: f64)
Moves the clock forward by ms, firing every timer that comes due
on the way, including ones those timers schedule.
Sourcepub fn run_due_timers(&self)
pub fn run_due_timers(&self)
Fires the timers due now, and the zero-delay timers they schedule, until none is left.
Trait Implementations§
Source§impl Scheduler for ManualScheduler
impl Scheduler for ManualScheduler
Source§fn checkpoint(&self, action: Box<dyn FnOnce()>)
fn checkpoint(&self, action: Box<dyn FnOnce()>)
Runs action before the next timer fires, or at the next
run_checkpoints.
Source§fn monotonic_now(&self) -> f64
fn monotonic_now(&self) -> f64
Milliseconds on a monotonic clock (
performance.now()).Auto Trait Implementations§
impl !Freeze for ManualScheduler
impl !RefUnwindSafe for ManualScheduler
impl !Send for ManualScheduler
impl !Sync for ManualScheduler
impl !UnwindSafe for ManualScheduler
impl Forget for ManualScheduler
impl Move for ManualScheduler
impl Unpin for ManualScheduler
impl UnsafeUnpin for ManualScheduler
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