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

Update tokio-udp to use std-future #1199

Merged
merged 4 commits into from
Jun 26, 2019
Merged

Conversation

blckngm
Copy link
Contributor

@blckngm blckngm commented Jun 26, 2019

Close #1195.

Changes:

  • recv_dgram, send_dgram, RecvDgram and SendDgram are replaced with send, recv,
    send_to and recv_from which return std Futures 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 that tokio-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 let tokio_udp depend on tokio for testing. Feels quite hacky. Let me know if there are better ways.

Copy link
Member

@LucioFranco LucioFranco left a 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

tokio-macros/src/lib.rs Show resolved Hide resolved
tokio-udp/src/lib.rs Show resolved Hide resolved
tokio-udp/src/recv.rs Outdated Show resolved Hide resolved
tokio-udp/src/socket.rs Outdated Show resolved Hide resolved
tokio-udp/src/socket.rs Outdated Show resolved Hide resolved
tokio-udp/src/socket.rs Show resolved Hide resolved
tokio-udp/src/socket.rs Outdated Show resolved Hide resolved
tokio-udp/src/socket.rs Outdated Show resolved Hide resolved
tokio-udp/src/socket.rs Outdated Show resolved Hide resolved
blckngm added 2 commits June 26, 2019 23:24
UdpSocket (actually PollEvented) does not panic when
polled outside of a task context anymore
Copy link
Member

@carllerche carllerche left a 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.

@carllerche
Copy link
Member

Thanks

@carllerche
Copy link
Member

Just need @LucioFranco to +1 as well.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM

@LucioFranco LucioFranco merged commit 6316aa1 into tokio-rs:master Jun 26, 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.

udp: update to std::future send_dgram doesn't work with connect on macOS Async/Await interface for UDP
3 participants