Enum MissedTickBehavior
pub enum MissedTickBehavior
Defines the behavior of an Interval when it misses a tick.
Sometimes, an Interval's tick is missed. For example, consider the
following:
use ;
# async
#
# async
Generally, a tick is missed if too much time is spent without calling
[Interval::tick()].
By default, when a tick is missed, Interval fires ticks as quickly as it
can until it is "caught up" in time to where it should be.
MissedTickBehavior can be used to specify a different behavior for
Interval to exhibit. Each variant represents a different strategy.
Note that because the executor cannot guarantee exact precision with timers, these strategies will only apply when the delay is greater than 5 milliseconds.
Variants
-
Burst Ticks as fast as possible until caught up.
When this strategy is used,
Intervalschedules ticks "normally" (the same as it would have if the ticks hadn't been delayed), which results in it firing ticks as fast as possible until it is caught up in time to where it should be. UnlikeDelayandSkip, the ticks yielded whenBurstis used (theInstants thattickyields) aren't different than they would have been if a tick had not been missed. LikeSkip, and unlikeDelay, the ticks may be shortened.This looks something like this:
Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 | Actual ticks: | work -----| delay | work | work | work -| work -----|In code:
use ; # async # # asyncThis is the default behavior when
Intervalis created withintervalandinterval_at.-
Delay Tick at multiples of
periodfrom whentickwas called, rather than fromstart.When this strategy is used and
Intervalhas missed a tick, instead of scheduling ticks to fire at multiples ofperiodfromstart(the time when the first tick was fired), it schedules all future ticks to happen at a regularperiodfrom the point whentickwas called. UnlikeBurstandSkip, ticks are not shortened, and they aren't guaranteed to happen at a multiple ofperiodfromstartany longer.This looks something like this:
Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 | Actual ticks: | work -----| delay | work -----| work -----| work -----|In code:
use ; # async # # async-
Skip Skips missed ticks and tick on the next multiple of
periodfromstart.When this strategy is used,
Intervalschedules the next tick to fire at the next-closest tick that is a multiple ofperiodaway fromstart(the point whereIntervalfirst ticked). LikeBurst, all ticks remain multiples ofperiodaway fromstart, but unlikeBurst, the ticks may not be one multiple ofperiodaway from the last tick. LikeDelay, the ticks are no longer the same as they would have been if ticks had not been missed, but unlikeDelay, and likeBurst, the ticks may be shortened to be less than oneperiodaway from each other.This looks something like this:
Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 | Actual ticks: | work -----| delay | work ---| work -----| work -----|In code:
use ; # async # # async
Trait Implementations
impl Clone for MissedTickBehavior
fn clone(&self) -> MissedTickBehavior
impl Copy for MissedTickBehavior
impl Debug for MissedTickBehavior
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for MissedTickBehavior
fn default() -> SelfReturns
MissedTickBehavior::Burst.For most usecases, the
Burststrategy is what is desired. Additionally, to preserve backwards compatibility, theBurststrategy must be the default. For these reasons,MissedTickBehavior::Burstis the default forMissedTickBehavior. SeeBurstfor more details.
impl Eq for MissedTickBehavior
impl PartialEq for MissedTickBehavior
fn eq(&self, other: &MissedTickBehavior) -> bool
impl StructuralPartialEq for MissedTickBehavior
Auto Trait Implementations
impl Freeze for MissedTickBehavior
impl RefUnwindSafe for MissedTickBehavior
impl Send for MissedTickBehavior
impl Sync for MissedTickBehavior
impl Unpin for MissedTickBehavior
impl UnsafeUnpin for MissedTickBehavior
impl UnwindSafe for MissedTickBehavior
Blanket Implementations
impl<T> Any for MissedTickBehavior
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for MissedTickBehavior
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for MissedTickBehavior
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for MissedTickBehavior
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for MissedTickBehavior
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for MissedTickBehavior
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for MissedTickBehavior
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for MissedTickBehavior
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for MissedTickBehavior
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>