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

time::Interval ticks during sleep on Windows but not on Linux #3184

Open
mahkoh opened this issue Nov 27, 2020 · 2 comments
Open

time::Interval ticks during sleep on Windows but not on Linux #3184

mahkoh opened this issue Nov 27, 2020 · 2 comments
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-time Module: tokio/time

Comments

@mahkoh
Copy link
Contributor

mahkoh commented Nov 27, 2020

fn poll_tick(&mut self, cx: &mut Context<'_>) -> Poll<Instant> {
// Wait for the delay to be done
ready!(Pin::new(&mut self.delay).poll(cx));
// Get the `now` by looking at the `delay` deadline
let now = self.delay.deadline();
// The next interval value is `duration` after the one that just
// yielded.
let next = now + self.period;
self.delay.reset(next);
// Return the current instant
Poll::Ready(now)
}

This code is affected by rust-lang/rust#79462

@mahkoh mahkoh added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Nov 27, 2020
@Darksonn Darksonn added the M-time Module: tokio/time label Nov 27, 2020
@Darksonn
Copy link
Contributor

Perhaps we should just add a line to the doc that we mirror std's behavior regarding sleep behavior, and what that behavior is at the time of writing.

@mahkoh
Copy link
Contributor Author

mahkoh commented Nov 27, 2020

This is not immediately connected to sleep. If tokio used a busy loop instead of sleeping, the difference in behavior would still be there. std::thread::sleep behaves the same way on windows and linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-time Module: tokio/time
Projects
None yet
Development

No branches or pull requests

2 participants