-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Update tokio-udp to use std-future #1199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for a first pass
UdpSocket (actually PollEvented) does not panic when polled outside of a task context anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 👍
We can polish anything else remaining in follow up PRs.
Thanks |
Just need @LucioFranco to +1 as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Close #1195.
Changes:
recv_dgram
,send_dgram
,RecvDgram
andSendDgram
are replaced withsend
,recv
,send_to
andrecv_from
which return stdFuture
s that borrows the socket, i.e., can be used with async/await. It's roughly the same API that runtime and romio offers. (Close Async/Await interface for UDP #616, Close send_dgram doesn't work with connect on macOS #1126.)The
poll...
functions are updated.UdpFramed
is removed (for now). It seems thattokio-codec
hasn't been updated yet. Besides, I think the framed API is not as useful as it used to be in v0.1:UdpFramed
produces/consumes owned buffers, which is the preferred way to deal with buffers when using combinators. But with async/await borrowed buffers can be used just fine.UdpFramed
can be split. But it incurs an unnecessary locking overhead. A specialized split should be implemented (like Consider a specialized split fn for TcpStream #174).Docs are updated.
Some basic tests are included. I have fixed and exposed the
tokio::test
macro and lettokio_udp
depend ontokio
for testing. Feels quite hacky. Let me know if there are better ways.