Skip to main content

Scheduler

Struct Scheduler 

Source
pub struct Scheduler { /* private fields */ }
Expand description

Tracks the state of every task and serves the next ready task by priority.

The scheduler owns the authoritative TaskRecord map. The executor pushes tasks in as they become runnable and pulls the highest-priority one out.

Implementations§

Source§

impl Scheduler

Source

pub fn new() -> Self

Create an empty scheduler.

Source

pub fn with_records(records: HashMap<String, TaskRecord>) -> Self

Seed the scheduler with previously persisted records (for recovery).

Source

pub fn ensure_record(&mut self, id: &str) -> &mut TaskRecord

Ensure a record exists for id, creating a Pending one if not.

Source

pub fn record(&self, id: &str) -> Option<&TaskRecord>

Immutable access to a record.

Source

pub fn records(&self) -> &HashMap<String, TaskRecord>

The full record map.

Source

pub fn records_mut(&mut self) -> &mut HashMap<String, TaskRecord>

Mutable access to the full record map.

Source

pub fn state(&self, id: &str) -> Option<TaskState>

Current state of id, if known.

Source

pub fn transition(&mut self, id: &str, state: TaskState) -> bool

Apply a state transition, returning whether it was legal/applied.

Source

pub fn mark_ready(&mut self, id: &str, priority: u8)

Mark id ready and enqueue it at priority.

Source

pub fn next_ready(&mut self) -> Option<String>

Pop the highest-priority task that is still in the Ready state.

Stale heap entries (whose record has since moved on) are discarded.

Source

pub fn has_ready(&self) -> bool

Whether any task is queued ready to run.

Source

pub fn all_terminal(&self) -> bool

Whether every known task has reached a terminal state.

Source

pub fn count_in(&self, state: TaskState) -> usize

Count records currently in state.

Trait Implementations§

Source§

impl Default for Scheduler

Source§

fn default() -> Scheduler

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more