t3hmrman / situwaition

⏲ situwaition is a Rust utility library that waits for conditions
https://crates.io/crates/situwaition
MIT License
6 stars 0 forks source link

Is it possible to set an infinite timeout? #10

Open ciresnave opened 3 months ago

ciresnave commented 3 months ago

Is it possible to have no timeout and wait for something forever? For example, I have a variable that may or may not ever change but need to check for it changing periodically. situwaition seems like a good crate to accomplish that except that I don't want a timeout. Instead, I want it to wait indefinitely. I'm sure I could wrap something around situwaition to start waiting again any time there is a timeout or I could simply set the timeout to such a ridiculously long duration that the timeout would never happen within the plausible run time of my code...but I figured I would ask if there was a way to actually specify that I don't want situwaition to time out.

t3hmrman commented 3 months ago

This is currently not implemented, but possible. For a quick workout you can set an obscene timeout length (generally I don't expect a system to be up for a solid year retrying the same check), but obviously that's not ideal.

I think one easy way to do this in a breaking change (new minor version) would be to make the timeout optional -- or an enum that represents running forever vs running with a timeout!