Skip to main content

spawn_periodic_loop

Function spawn_periodic_loop 

Source
fn spawn_periodic_loop<F, Fut>(
    name: &'static str,
    period: Duration,
    shutdown_rx: Receiver<bool>,
    handler: F,
) -> JoinHandle<()>
where F: FnMut() -> Fut + Send + 'static, Fut: Future<Output = ()> + Send + 'static,
Expand description

Spawn a periodic background loop for a single timer.

A handler is never re-entered: if it runs longer than its period, the next tick is delayed. Shutdown is observed between handler runs, which matches the legacy timer loop semantics.