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
impl Scheduler
Sourcepub fn with_records(records: HashMap<String, TaskRecord>) -> Self
pub fn with_records(records: HashMap<String, TaskRecord>) -> Self
Seed the scheduler with previously persisted records (for recovery).
Sourcepub fn ensure_record(&mut self, id: &str) -> &mut TaskRecord
pub fn ensure_record(&mut self, id: &str) -> &mut TaskRecord
Ensure a record exists for id, creating a Pending one if not.
Sourcepub fn record(&self, id: &str) -> Option<&TaskRecord>
pub fn record(&self, id: &str) -> Option<&TaskRecord>
Immutable access to a record.
Sourcepub fn records(&self) -> &HashMap<String, TaskRecord>
pub fn records(&self) -> &HashMap<String, TaskRecord>
The full record map.
Sourcepub fn records_mut(&mut self) -> &mut HashMap<String, TaskRecord>
pub fn records_mut(&mut self) -> &mut HashMap<String, TaskRecord>
Mutable access to the full record map.
Sourcepub fn transition(&mut self, id: &str, state: TaskState) -> bool
pub fn transition(&mut self, id: &str, state: TaskState) -> bool
Apply a state transition, returning whether it was legal/applied.
Sourcepub fn mark_ready(&mut self, id: &str, priority: u8)
pub fn mark_ready(&mut self, id: &str, priority: u8)
Mark id ready and enqueue it at priority.
Sourcepub fn next_ready(&mut self) -> Option<String>
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.
Sourcepub fn all_terminal(&self) -> bool
pub fn all_terminal(&self) -> bool
Whether every known task has reached a terminal state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scheduler
impl RefUnwindSafe for Scheduler
impl Send for Scheduler
impl Sync for Scheduler
impl Unpin for Scheduler
impl UnsafeUnpin for Scheduler
impl UnwindSafe for Scheduler
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