-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
time::advance advances too far when given a Duration of sub-millisecond granularity #3837
Comments
We should probably have had a test for this. Thanks for spotting it. |
I believe this behavior was designed because the driver does this https://github.com/tokio-rs/tokio/blob/master/tokio/src/time/driver/mod.rs#L111? So technically during normal operation (not in test mode) tokio would round up and I think it makes sene for the mock clock to do the same? |
|
Actually, more robust is probably checking when the next timer expiration is and comparing to that. |
Is someone fixing this problem? |
This broke my tests :( rolled back 1.5 |
Update the advance logic to factor in the timer's ms rounding. Fixes #3837
Update the advance logic to factor in the timer's ms rounding. Fixes #3837
Version
Platform
Darwin Kernel Version 19.6.0
Description
time::advance
advances time too far when it's given a Duration of sub-millisecond granularity. This worked prior to this commit, which was included in tokio 1.6 2b9b558I assume this is happening because the above commit updates
time::advance
to usesleep_until
, which operates at millisecond granularity.Here's some code to reproduce the issue:
I expected the duration elapsed to be the exact duration passed to
time::advance
.Instead, the duration elapsed was the duration passed to
time::advance
plus an additional millisecond.cc: @LucioFranco
The text was updated successfully, but these errors were encountered: