pub trait Resolution {
    const MAX_DURATION: Duration;

    // Required methods
    fn cycle_steps(duration: &Duration, upper_bound: bool) -> u32;
    fn whole_steps(duration: &Duration) -> u128;
    fn steps_as_duration(steps: u64) -> Duration;
}
Expand description

A timer resolution.

A coarser resolution might improve scheduling performance of tasks where delays would exceed the 2^32 steps with finer resolutions.

Note that with the current design it’s not possible to know when the earliest next task is scheduled, only which buckets are empty, thus resource saving optimizations can only take buckets into account. E.g. using seconds as a resolution will always cause a busy wait as long as there is a task that will expire within the next 255 seconds.

Required Associated Constants§

source

const MAX_DURATION: Duration

The maximum duration that can be represented as u32 at this resolution.

Required Methods§

source

fn cycle_steps(duration: &Duration, upper_bound: bool) -> u32

Convert the given duration into timer cycle steps. The given duration is guaranteed to be smaller than Resolution::MAX_DURATION.

If upper_bound is set, the returned value should be rounded up.

source

fn whole_steps(duration: &Duration) -> u128

Return total steps required for the given duration. The returned steps should not be rounded up.

source

fn steps_as_duration(steps: u64) -> Duration

Convert the given steps to a duration.

Implementors§