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

Partial workaround for timer during a clock jump #196

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vincentbernat
Copy link
Contributor

@vincentbernat vincentbernat commented Jan 2, 2017

time.Now() uses the wall-clock and therefore calling it twice, one
second apart, can produce quite different results (negative results but
also a difference greater than one second). Go doesn't expose a
monotonic clock, therefore, it's difficult to properly fix (but there is
https://github.com/gavv/monotime if we want a proper fix for
timer.Time()).

This workaround just discard any negative duration.

There are other places that incorrectly uses time.Now(). I can add a similar check or I can import monotime to properly fixes them.

`time.Now()` uses the wall-clock and therefore calling it twice, one
second apart, can produce quite different results (negative results but
also a difference greater than one second). Go doesn't expose a
monotonic clock, therefore, it's difficult to properly fix (but there is
https://github.com/gavv/monotime if we want a proper fix for
`timer.Time()`).

This workaround just discard any negative duration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant