pub trait Scheduler {
// Required methods
fn now(&self) -> f64;
fn monotonic_now(&self) -> f64;
fn schedule(&self, ms: f64, action: Box<dyn FnOnce()>) -> Box<dyn Timer>;
fn schedule_repeating(
&self,
ms: f64,
action: Box<dyn FnMut()>,
) -> Box<dyn Timer>;
fn checkpoint(&self, action: Box<dyn FnOnce()>);
}Expand description
The clock and timers the engine runs on: Date.now(),
performance.now() and setTimeout in JS. Tests use
ManualScheduler so a scenario runs
the same way every time; an app’s transport provides one that runs on
its event loop.
The engine is single-threaded: every action runs on the thread that made the client.
Required Methods§
Sourcefn monotonic_now(&self) -> f64
fn monotonic_now(&self) -> f64
Milliseconds on a monotonic clock (performance.now()).
Sourcefn schedule(&self, ms: f64, action: Box<dyn FnOnce()>) -> Box<dyn Timer>
fn schedule(&self, ms: f64, action: Box<dyn FnOnce()>) -> Box<dyn Timer>
Calls action after ms milliseconds.
Sourcefn schedule_repeating(
&self,
ms: f64,
action: Box<dyn FnMut()>,
) -> Box<dyn Timer>
fn schedule_repeating( &self, ms: f64, action: Box<dyn FnMut()>, ) -> Box<dyn Timer>
Calls action every ms milliseconds until cancelled (setInterval).
Sourcefn checkpoint(&self, action: Box<dyn FnOnce()>)
fn checkpoint(&self, action: Box<dyn FnOnce()>)
Calls action once the caller’s synchronous code is done, before any
timer: where JS runs microtasks. The engine queues its follow-ups to
API calls here.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".