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

Fix Handle::timeout #1093

Merged
merged 2 commits into from
Jul 8, 2019
Merged

Conversation

sfackler
Copy link
Contributor

Motivation

The old implementation didn't work for Timeout, since the method
took a deadline rather than a timeout.

Solution

timeout now takes a Duration rather than Instant, and plumbs things through so that the inner Delay will be reset appropriately. This is a breaking change, so it shouldn't be backported to 1.x

sfackler added 2 commits May 15, 2019 11:13
The old implementation didn't work for Timeout<Stream>, since the method
took a deadline rather than a timeout.
@seanmonstar
Copy link
Member

Master is now ready for breaking changes, so I'd happily merge, but I want to better understand: what was wrong originally?

@sfackler
Copy link
Contributor Author

Timeout<Stream> applies the timeout to each value out of the stream rather than acting as a deadline for all of the values in aggregate. But, for that to work you need to provide a Duration rather than an Instant.

@seanmonstar
Copy link
Member

Ohhhh, got it!

Some(ref handle_priv) => Delay::new_with_handle(deadline, handle_priv.clone()),
None => Delay::new(deadline),
Some(ref handle_priv) => {
Delay::new_with_handle(deadline, Duration::from_secs(0), handle_priv.clone())
Copy link
Member

Choose a reason for hiding this comment

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

Should this pass the above duration, instead of creating a 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The second duration there is the magic reset interval that's used by Timeout<Stream>. Delay's normal public constructor sets it to 0 as well.

@carllerche carllerche merged commit b62d224 into tokio-rs:master Jul 8, 2019
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.

3 participants