pub struct Scheduler<'t> { /* private fields */ }Expand description
The deterministic task scheduler.
Implementations§
Source§impl<'t> Scheduler<'t>
impl<'t> Scheduler<'t>
Sourcepub fn new(config: SchedulerConfig, chooser: Chooser) -> Self
pub fn new(config: SchedulerConfig, chooser: Chooser) -> Self
A fresh scheduler with the given config and decision source.
Sourcepub fn new_chan(&mut self, capacity: Option<usize>) -> ChanId
pub fn new_chan(&mut self, capacity: Option<usize>) -> ChanId
Create a channel with an explicit capacity (None = unbounded, Some(0) = rendezvous).
Sourcepub fn new_default_chan(&mut self) -> ChanId
pub fn new_default_chan(&mut self) -> ChanId
Create a channel with the config’s default capacity.
Sourcepub fn spawn(&mut self, task: Box<dyn Task<'t> + 't>) -> TaskId
pub fn spawn(&mut self, task: Box<dyn Task<'t> + 't>) -> TaskId
Spawn a task. Returns its id; it is enqueued ready.
Sourcepub fn spawn_main(&mut self, task: Box<dyn Task<'t> + 't>) -> TaskId
pub fn spawn_main(&mut self, task: Box<dyn Task<'t> + 't>) -> TaskId
Spawn the main task — its Exit value becomes the run’s RunOutcome::Done payload.
Sourcepub fn into_trace(self) -> SchedTrace
pub fn into_trace(self) -> SchedTrace
Consume the scheduler and return the recorded scheduling trace.
Sourcepub fn run(&mut self) -> RunOutcome
pub fn run(&mut self) -> RunOutcome
Run cooperatively to quiescence.
Sourcepub fn poll_once(&mut self) -> Option<RunOutcome>
pub fn poll_once(&mut self) -> Option<RunOutcome>
Advance the scheduler by a single step: dispatch one ready task, or (if none is
ready) advance the timer wheel. Returns Some(outcome) only at quiescence — when no
task is ready and no timer can fire — and None while there is still work to do.
run is poll_once to a fixpoint; the browser drive loop calls it in slices,
yielding a macrotask between them so the UI repaints. Both produce identical
behavior and identical traces by construction.
Sourcepub fn run_slice(&mut self, max_steps: usize) -> Option<RunOutcome>
pub fn run_slice(&mut self, max_steps: usize) -> Option<RunOutcome>
Run at most max_steps steps. Returns Some(outcome) if quiescence was reached
within the budget, or None if work remains (the caller should yield and call
again). A max_steps of 0 makes no progress and returns None.
Sourcepub fn wake_io(&mut self) -> bool
pub fn wake_io(&mut self) -> bool
Re-ready every task parked on external I/O ([TaskState::BlockedIo]), in ascending
id order (deterministic). The async drive loop calls this after yielding to the host
reactor so the parked tasks re-poll their network futures. Returns whether any task was
woken. Channel/timer tasks are untouched, so a non-networking program never sees this.
Sourcepub fn snapshot(&self) -> SchedSnapshot
pub fn snapshot(&self) -> SchedSnapshot
A deterministic, read-only snapshot of the current task and channel state — emitted between slices to drive the Studio’s Tasks/Channels strip. Tasks and channels are sorted by id so the UI order is stable across snapshots.