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
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