[GH-ISSUE #167] Borrow Handles, don't consume them #79

Closed
opened 2026-03-07 22:18:37 +03:00 by kerem · 5 comments
Owner

Originally created by @rushmorem on GitHub (Jul 20, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/167

I noticed a number of methods (eg UdpStream::new) consume tokio_core::reactor::Handle instead of simply borrowing it since the underlying methods only require references. This results in unnecessary cloning in client code.

Originally created by @rushmorem on GitHub (Jul 20, 2017). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/167 I noticed a number of methods (eg `UdpStream::new`) consume `tokio_core::reactor::Handle` instead of simply borrowing it since the underlying methods only require references. This results in unnecessary cloning in client code.
kerem closed this issue 2026-03-07 22:18:38 +03:00
Author
Owner

@bluejekyll commented on GitHub (Jul 20, 2017):

Hmm. Did this change in recent Tokio versions?

I think AsRef as the parameter change would fix this without creating a breaking change.

<!-- gh-comment-id:316693889 --> @bluejekyll commented on GitHub (Jul 20, 2017): Hmm. Did this change in recent Tokio versions? I think AsRef<Handle> as the parameter change would fix this without creating a breaking change.
Author
Owner

@rushmorem commented on GitHub (Jul 20, 2017):

Did this change in recent Tokio versions?

As long as I remember, this has always been the case. Methods in Tokio have always borrowed Handle.

<!-- gh-comment-id:316697439 --> @rushmorem commented on GitHub (Jul 20, 2017): > Did this change in recent Tokio versions? As long as I remember, this has always been the case. Methods in Tokio have always borrowed `Handle`.
Author
Owner

@bluejekyll commented on GitHub (Jul 20, 2017):

Huh. I don't know why I would have made that mistake. I'm on a family vacation right now. I might be able to get to this at some point this week. Otherwise a PR is always welcome.

<!-- gh-comment-id:316700615 --> @bluejekyll commented on GitHub (Jul 20, 2017): Huh. I don't know why I would have made that mistake. I'm on a family vacation right now. I might be able to get to this at some point this week. Otherwise a PR is always welcome.
Author
Owner

@rushmorem commented on GitHub (Jul 20, 2017):

I think AsRef as the parameter change would fix this without creating a breaking change.

IMHO it might actually be desirable to make this a breaking change otherwise people might not be aware of it.

I'm on a family vacation right now. I might be able to get to this at some point this week. Otherwise a PR is always welcome.

Don't worry about it. Please enjoy your vacation. I will work on this and submit a pull request.

<!-- gh-comment-id:316708419 --> @rushmorem commented on GitHub (Jul 20, 2017): > I think AsRef as the parameter change would fix this without creating a breaking change. IMHO it might actually be desirable to make this a breaking change otherwise people might not be aware of it. > I'm on a family vacation right now. I might be able to get to this at some point this week. Otherwise a PR is always welcome. Don't worry about it. Please enjoy your vacation. I will work on this and submit a pull request.
Author
Owner

@bluejekyll commented on GitHub (Jul 20, 2017):

make this a breaking change otherwise people might not be aware of it.

Yeah. I thought about that. It makes sense, I'll plan on a 0.11 release for this in a little bit in that case.

And thanks for the PR!

<!-- gh-comment-id:316754108 --> @bluejekyll commented on GitHub (Jul 20, 2017): > make this a breaking change otherwise people might not be aware of it. Yeah. I thought about that. It makes sense, I'll plan on a 0.11 release for this in a little bit in that case. And thanks for the PR!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#79
No description provided.