Closed 4e554c4c closed 2 years ago
I tried rewriting the project using async and tokio (can PR if desired) but this did not help. sleep_until
suffers from the same issue, as do other realtime clocks. the solution would probably be to use shorter sleeps; say ~10s
I think this is a valid issue. I was going to have a look at using sleep_until as you suggested, but if that doesn't actually help then I don't see much point in converting to async just yet. Thanks for saving me the effort of testing, though.
I'll think on it a bit more - in not blown away by waking up every n
seconds... It seems a bit arbitrary/inefficient... There must be a better way!
Yeah, this is solvable in C using alarms with TIMER_ABSTIME
, so it's possible without tons of sleeps (also I have learned that the spin_sleep crate exists to solve this problem)... there just don't seem to be very good interfaces to it.
Would you accept a PR that adds a CFG to fix this only on unix systems? I'm afraid I have no windows experience, so that's the furthest I'll be able to go fixing it.
Yes, Unix-only for now is good. The primary target for heliocron was things like raspberry pis, where Unix OSes are ubiquitous.
When my laptop goes to sleep, or is suspended, heliocron sleeps for far too long. I suspect this is because its main
std::thread::sleep
call does not make progress while the system itself is suspended. This is expected behavior according to the sleep docs, so heliocron shouldn't be using this call. A better alternative would probably be sleep_until from tokio, but that would require an async rewrite.