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
@mcc You have that problem if you wake up on time, too (expired sleep will remain expired forever). Hacky solution: reset it to some time in far future.
But your setup with Either need not require creating and destroying the future all the time: you can make an `Either<&Sleep, SomethingElse>` (well, remake it each iteration).