-
Notifications
You must be signed in to change notification settings - Fork 247
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
listen uses Time.now for time intervals; should use Monotonic tick count #510
Comments
@ioquatix Curious to get your opinion here. |
Just use the Ruby interface don't pull in a dependency for it. |
Sounds good to avoid dependencies. I wonder if we'll have trouble with some Ruby versions not supporting |
You can ignore any version that doesn't support it, they should all be EOL. |
Sounds good. |
Sure, if you are happy with that, I am happy with it. It's no worse than it currently is. |
From reading the documentation, it seems like those constants are more OS-specific than Ruby-version-specific. So just in case, I wrote the code to be adaptive and prefer |
I have not seen a platform where |
Current State
The
'listen
gem uses theTime.now
clock for measuring time intervals. For example, from base.rb:This is a bug since the
Time.now
timer may be updated at any time, forward or backward. Most commonly byntp
.Desired State
The
'listen
gem should use the Monotonic tick count instead for time intervals. There are several gems that encapsulate this, including https://github.com/Freaky/monotime, https://github.com/invoca/monotonic_tick_count. Perhaps best for portability and minimal coupling, concurrent-ruby has a simple encapsulation asmonotonic_time
.Steps to Reproduce
I didn't try, but you could reproduce the bug by adjusting the system clock while
listen
is running. If you adjusted the clock forward by, say, 1 second, you could trick the_wait_until_events_calm_down
method into thinking it didn't need to wait at all, thus leading to duplicate events.The text was updated successfully, but these errors were encountered: