pub struct TimeoutContainer { /* private fields */ }Implementations§
Source§impl TimeoutContainer
impl TimeoutContainer
pub fn new(duration: Duration, token: Token) -> TimeoutContainer
pub fn new_empty(duration: Duration) -> TimeoutContainer
pub fn take(&mut self) -> TimeoutContainer
Sourcepub fn triggered(&mut self)
pub fn triggered(&mut self)
must be called when a timeout was triggered, to prevent errors when canceling
pub fn set(&mut self, token: Token)
Sourcepub fn set_at(&mut self, token: Token, deadline: Instant)
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.
Sourcepub fn set_duration(&mut self, duration: Duration)
pub fn set_duration(&mut self, duration: Duration)
warning: this does not reset the timer
pub fn duration(&self) -> Duration
Sourcepub fn retune(&mut self, duration: Duration)
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.
Sourcepub fn is_armed(&self) -> bool
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.
Sourcepub fn deadline(&self) -> Option<Instant>
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.