What is Nostr?
mcc /
npub15vt…x8ma
2025-01-15 22:32:42

mcc on Nostr: I am in Rust using tokio. I know I can set up a tokio loop to wake every half second ...

I am in Rust using tokio.

I know I can set up a tokio loop to wake every half second with

let period = std::time::Duration::from_secs_f32(0.5);
let mut interval = tokio::time::interval(period);

loop {
tokio::select! {
_ = interval.tick() => {}

And I know I can reset() the loop to say "forget what schedule you were on".

Is there a way to do this, but have the interval wake ONLY WHEN IT WAS RESET? i.e. it fires half a second after reset() but at no other time
Author Public Key
npub15vtzh9eq7663ttzt6gk4af9t7ru97459zvxu5s85dlngfl59kf2srvx8ma