Skip to main content

Deadline

Struct Deadline 

Source
pub struct Deadline<'a> { /* private fields */ }
Expand description

A running bound. Make it with Deadline::start (polling) or Deadline::paced (sleeping), ask Deadline::expired once per look, and call Deadline::pause between looks.

Implementations§

Source§

impl<'a> Deadline<'a>

Source

pub fn start(ctx: &'a ServiceContext, budget: Budget) -> Self

A polling deadline: Deadline::pause is only a spin hint. On an uncalibrated machine the budget becomes UNCALIBRATED_POLLS looks.

Source

pub fn paced(ctx: &'a ServiceContext, budget: Budget, pace: Budget) -> Self

A deadline whose looks are pace apart: call Deadline::pause between them. The pace is in whole milliseconds, the unit sleep_ms takes, and at least one. Only ARMv7 (the Pi 2) has a sub-tick timer for a sleep; every other port ends one on its scheduler tick, so there a pace shorter than a quantum (nominally 10 ms) lasts about one. On an uncalibrated machine the budget becomes as many looks as the pace fits into it.

Source

pub fn pause(&self)

Wait out one pace between looks: a sleep for a paced deadline, a spin hint for a polling one.

Source

pub fn expired(&mut self) -> bool

Has the budget run out? Call it once per look, AFTER checking the condition, so a condition already true costs no clock read at all.

Source

pub fn elapsed_us(&self) -> u64

Microseconds since the start, for a caller that reports how long a wait took. 0 when uncalibrated, where it cannot be known.

Auto Trait Implementations§

§

impl<'a> Freeze for Deadline<'a>

§

impl<'a> RefUnwindSafe for Deadline<'a>

§

impl<'a> Send for Deadline<'a>

§

impl<'a> Sync for Deadline<'a>

§

impl<'a> Unpin for Deadline<'a>

§

impl<'a> UnsafeUnpin for Deadline<'a>

§

impl<'a> UnwindSafe for Deadline<'a>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.