pub struct Scheduler<'a, C, T, E = Error> {
    pub tasks: &'a mut [Task<T, E>],
    pub clock: C,
    pub tick: u16,
    pub max_task_slowdown: u8,
    pub loop_rate_hz: i16,
    pub task_not_achieved: u32,
    pub task_all_achieved: u32,
    pub loop_timer_start_us: u32,
    pub last_loop_time_s: f32,
    pub extra_loop_us: u32,
    /* private fields */
}
Expand description

Task scheduler for flight controllers

Fields

tasks: &'a mut [Task<T, E>]

The tasks to run in order of highest to lowest priority.

clock: C

The clock used for timing.

tick: u16

The current tick, incremented each run.

max_task_slowdown: u8

The maximum amount of ticks a task can miss before slowing down the scheduler.

loop_rate_hz: i16

The desired loop rate to run (in hz).

task_not_achieved: u32

The amount of ticks with tasks that exceed the max_task_slowdown.

task_all_achieved: u32

The amount of ticks with tasks that remain in the max_task_slowdown.

loop_timer_start_us: u32

The start time of the run loop (in microseconds).

last_loop_time_s: f32

The start time of the run loop (in seconds).

extra_loop_us: u32

Extra time to spend in the loop to catch up on tasks not achieved (in microseconds).

Implementations

Create a new scheduler from a slice of tasks, a clock, and the loop rate (in hz)

Calculate the time available and run as many tasks as possible.

Run as many tasks as possible in the given time_available.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.