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

feat: add timer support for legacy::Pool #84

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

dswij
Copy link
Member

@dswij dswij commented Dec 28, 2023

Addresses hyperium/hyper#3167

Note that previously we're using tokio's Interval rather than Sleep. This PR tries to emulate the behavior for Pool using Sleep instead, so that:

  1. No extra trait for Interval
  2. User only needs to supply a Timer rather than a Timer and also an Interval.

@@ -1374,11 +1397,11 @@ impl Builder {
/// [`h2::client::Builder::timer`]: https://docs.rs/h2/client/struct.Builder.html#method.timer
pub fn timer<M>(&mut self, timer: M) -> &mut Self
where
M: Timer + Send + Sync + 'static,
M: Timer + Clone + Send + Sync + 'static,
Copy link
Member

Choose a reason for hiding this comment

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

Woops. Adding this would technically be breaking.

I suppose we could just wrap it in the local Timer struct, and pass that? It will mean double Arc-dyn, which is unfortunate. Maybe we can find a clever way to indicate to hyper::rt::Timer that we don't need to double Arc it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops yeah you're right, forgot about this one.

For avoiding double Arc-dyn, we can probably come up with something using Deref and or TryFrom, though I feel it's a bit hacky. (something like, if it's from local Timer then don't need to wrap Arc)

I was playing around with unwrap_or_clone just to realize it's still experimental. 😅 https://doc.rust-lang.org/std/sync/struct.Arc.html#method.unwrap_or_clone

@seanmonstar seanmonstar merged commit 784109d into hyperium:master Jan 8, 2024
15 checks passed
@dswij dswij deleted the pool-timer-interval branch January 9, 2024 03:43
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.

2 participants