Skip to main content

TimeoutContainer

Struct TimeoutContainer 

Source
pub struct TimeoutContainer { /* private fields */ }

Implementations§

Source§

impl TimeoutContainer

Source

pub fn new(duration: Duration, token: Token) -> TimeoutContainer

Source

pub fn new_empty(duration: Duration) -> TimeoutContainer

Source

pub fn take(&mut self) -> TimeoutContainer

Source

pub fn triggered(&mut self)

must be called when a timeout was triggered, to prevent errors when canceling

Source

pub fn set(&mut self, token: Token)

Source

pub fn set_at(&mut self, token: Token, deadline: Instant)

Arm the entry so it fires at deadline rather than one full Self::duration from now, leaving the configured duration untouched.

This is what a holder uses to put an entry BACK after the wheel handed it over early: re-arming with Self::set would push the deadline out by a fresh full duration, so an entry delivered a few tens of milliseconds before a 60 s timeout would fire at ~120 s — silently doubling the operator’s configured timeout on every early delivery.

A deadline that has already passed arms the shortest entry the wheel can express (set_timeout_at forces at least one tick ahead), so the caller is called back promptly rather than never — and, because that clamp exists, never spins: a zero-length delay still costs a whole tick.

Source

pub fn set_duration(&mut self, duration: Duration)

warning: this does not reset the timer

Source

pub fn duration(&self) -> Duration

Source

pub fn retune(&mut self, duration: Duration)

Adopt a new configured duration without touching the armed entry.

Self::set_duration cancels and re-arms; an owner that drives arming itself through Self::set_at must not pay that, and must not have its entry moved behind its back. The duration still has to be kept current, because a container handed on to another protocol state — the WebSocket upgrade path hands the mux’s containers to Pipe, which calls Self::reset — re-arms from it.

Source

pub fn is_armed(&self) -> bool

Whether a wheel entry is currently held.

Distinct from deadline().is_some() only while the two are out of step, which is exactly the state an owner that memoizes on the deadline must be able to see: after Self::triggered both are cleared together, but an owner keeping its own deadline mirror can believe an entry is armed when the wheel has already handed it over. That belief is the lost wakeup, so the check is available rather than inferred.

Source

pub fn deadline(&self) -> Option<Instant>

The absolute instant the armed entry is meant to fire at, or None when nothing is armed. See the field documentation: this is the mirror of the wheel entry, and the only way to tell an early delivery from a real expiry.

Source

pub fn cancel(&mut self) -> bool

Source

pub fn reset(&mut self) -> bool

Trait Implementations§

Source§

impl Clone for TimeoutContainer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimeoutContainer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TimeoutContainer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for TimeoutContainer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.