Skip to content

Update futures-timer to 3.0.2 #739

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

Merged
merged 1 commit into from
Apr 3, 2020
Merged

Update futures-timer to 3.0.2 #739

merged 1 commit into from
Apr 3, 2020

Conversation

devashishdxt
Copy link
Contributor

No description provided.

Verified

This commit was signed with the committer’s verified signature.
psteinroe Philipp Steinrötter
@devashishdxt
Copy link
Contributor Author

I didn't check before creating a PR. Another PR for this is already open #738

Comment on lines -95 to -113
fn next_interval(prev: Instant, now: Instant, interval: Duration) -> Instant {
let new = prev + interval;
if new > now {
return new;
}

let spent_ns = duration_to_nanos(now.duration_since(prev)).expect("interval should be expired");
let interval_ns =
duration_to_nanos(interval).expect("interval is less that 427 thousand years");
let mult = spent_ns / interval_ns + 1;
assert!(
mult < (1 << 32),
"can't skip more than 4 billion intervals of {:?} \
(trying to skip {})",
interval,
mult
);
prev + interval * (mult as u32)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this logic, but is it safe to remove it?

Copy link
Contributor Author

@devashishdxt devashishdxt Apr 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The logic is quite complex and there is not much documentation for next_interval function. But, as the name suggests, it is trying to find the next Instant to update the Delay with. As the new version of Delay already takes Duration as argument, we don't have to go through that complex logic to find the next Instant.

Copy link
Member

@k-nasa k-nasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@k-nasa k-nasa merged commit 6674dc0 into async-rs:master Apr 3, 2020
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.

None yet

2 participants