pub struct PeriodicTick<'ctx> { /* private fields */ }Expand description
One tick of a ThreadpoolPeriodicTimer, handed to its callback.
A tick may be running concurrently with other ticks of the same timer, so anything this callback touches must tolerate that.
Implementations§
Source§impl PeriodicTick<'_>
impl PeriodicTick<'_>
Sourcepub fn stop(&self)
pub fn stop(&self)
Stop the timer from inside its own callback.
This is how a periodic timer ends itself – “tick until some condition holds” needs no external coordination.
It stops future ticks being queued, and discards a tick already queued
– the behaviour
stopping_a_periodic_timer_discards_a_tick_that_is_already_queued
measures for ThreadpoolPeriodicTimer::stop, which this calls. What
it does not affect is a tick already running, including another
concurrent run of this same callback on another thread. Expect the
callback to run again after calling this, and make it idempotent
accordingly.