Enum MissedTickBehavior
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
Implementations
impl Clone for MissedTickBehavior
fn clone(self: &Self) -> MissedTickBehavior
impl Copy for MissedTickBehavior
impl Debug for MissedTickBehavior
fn fmt(self: &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 Freeze for MissedTickBehavior
impl PartialEq for MissedTickBehavior
fn eq(self: &Self, other: &MissedTickBehavior) -> bool
impl RefUnwindSafe for MissedTickBehavior
impl Send for MissedTickBehavior
impl StructuralPartialEq for MissedTickBehavior
impl Sync for MissedTickBehavior
impl Unpin for MissedTickBehavior
impl UnsafeUnpin for MissedTickBehavior
impl UnwindSafe for MissedTickBehavior
impl<T> Any for MissedTickBehavior
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for MissedTickBehavior
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for MissedTickBehavior
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for MissedTickBehavior
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for MissedTickBehavior
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for MissedTickBehavior
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for MissedTickBehavior
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for MissedTickBehavior
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for MissedTickBehavior
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>