Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Instant instead of SystemTime #42

Open
uazu opened this issue Mar 8, 2019 · 2 comments

Comments

@uazu
Copy link

commented Mar 8, 2019

Instant is intended to be used for timers. SystemTime can go backwards, e.g. if the system clock is adjusted. If the clock goes backwards, then everything relying on a timer would stop working until time catches up again (e.g. hours/days later). See the docs in the std lib.

@mkj

This comment has been minimized.

Copy link

commented Aug 23, 2019

Instant makes sense for delay or interval values. What about schedule_at_time, I guess that kind of has to be real-world clock?

https://github.com/riker-rs/riker/blob/master/src/system/timer.rs#L128 looks like it needs a distinction between jobs using Instant jobs, and jobs using SystemTime.

@uazu

This comment has been minimized.

Copy link
Author

commented Aug 23, 2019

Personally I'd run everything on Instant time. How many tools actually need to schedule things by wall clock time? Perhaps only cron, or personal assistant / scheduling type tools. Also since SystemTime can go backwards, there is no way to reliably trigger on a particular time being reached. So if you need to use wall clock time, either you estimate how long before SystemTime will reach the desired time, and wait for that in terms of Instant time, or else if you really care about noticing when SystemTime changes unexpectedly, you'd need to poll it at intervals. Those few cases can be handled in application code, since the application knows what tradeoffs it is happy with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.