Skip to main content

Scheduler

Struct Scheduler 

Source
pub struct Scheduler<'t> { /* private fields */ }
Expand description

The deterministic task scheduler.

Implementations§

Source§

impl<'t> Scheduler<'t>

Source

pub fn new(config: SchedulerConfig, chooser: Chooser) -> Self

A fresh scheduler with the given config and decision source.

Source

pub fn new_chan(&mut self, capacity: Option<usize>) -> ChanId

Create a channel with an explicit capacity (None = unbounded, Some(0) = rendezvous).

Source

pub fn new_default_chan(&mut self) -> ChanId

Create a channel with the config’s default capacity.

Source

pub fn spawn(&mut self, task: Box<dyn Task<'t> + 't>) -> TaskId

Spawn a task. Returns its id; it is enqueued ready.

Source

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.

Source

pub fn into_trace(self) -> SchedTrace

Consume the scheduler and return the recorded scheduling trace.

Source

pub fn run(&mut self) -> RunOutcome

Run cooperatively to quiescence.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'t> Freeze for Scheduler<'t>

§

impl<'t> !RefUnwindSafe for Scheduler<'t>

§

impl<'t> !Send for Scheduler<'t>

§

impl<'t> !Sync for Scheduler<'t>

§

impl<'t> Unpin for Scheduler<'t>

§

impl<'t> UnsafeUnpin for Scheduler<'t>

§

impl<'t> !UnwindSafe for Scheduler<'t>

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.