Trait task::scheduler::Scheduler

source ·
pub trait Scheduler: Send + Sync + 'static {
    // Required methods
    fn next(&mut self) -> TaskRef;
    fn add(&mut self, task: TaskRef);
    fn busyness(&self) -> usize;
    fn remove(&mut self, task: &TaskRef) -> bool;
    fn as_priority_scheduler(&mut self) -> Option<&mut dyn PriorityScheduler>;
    fn drain(&mut self) -> Box<dyn Iterator<Item = TaskRef> + '_>;
    fn tasks(&self) -> Vec<TaskRef>;
}
Expand description

A task scheduler.

Required Methods§

source

fn next(&mut self) -> TaskRef

Returns the next task to run.

source

fn add(&mut self, task: TaskRef)

Adds a task to the run queue.

source

fn busyness(&self) -> usize

Returns a measure of how busy the scheduler is, with higher values representing a busier scheduler.

source

fn remove(&mut self, task: &TaskRef) -> bool

Removes a task from the run queue.

source

fn as_priority_scheduler(&mut self) -> Option<&mut dyn PriorityScheduler>

Returns a reference to this scheduler as a priority scheduler, if it is one.

source

fn drain(&mut self) -> Box<dyn Iterator<Item = TaskRef> + '_>

Clears the scheduler’s runqueue, returning an iterator over all contained tasks.

source

fn tasks(&self) -> Vec<TaskRef>

Returns a cloned list of contained tasks being scheduled by this scheduler.

The list should be considered out-of-date as soon as it is called, but can be useful as a heuristic or for debugging.

Implementors§