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

meta: update to std::future and release an alpha. #1201

Closed
17 of 23 tasks
carllerche opened this issue Jun 26, 2019 · 19 comments
Closed
17 of 23 tasks

meta: update to std::future and release an alpha. #1201

carllerche opened this issue Jun 26, 2019 · 19 comments
Milestone

Comments

@carllerche
Copy link
Member

@carllerche carllerche commented Jun 26, 2019

This issue tracks the progress of updating Tokio to use std::future.

Crates to update

Examples

The examples should be updated to idiomatic async / await syntax.

  • blocking
  • chat-combinator-current-thread
  • chat-combinator
  • chat
  • connect
  • echo-udp
  • echo
  • hello_world
  • manual-runtime
  • print_each_packet
  • proxy
  • tinydb
  • tinyhttp
  • udp-client
  • udp-codec

Additional functionality

Besides requiring crates to have transitioned to std::future, some examples are blocked on additional functionality being added.

Alpha release

The first alpha release will happen once the examples have been updated.

@rubdos
Copy link
Contributor

@rubdos rubdos commented Jun 29, 2019

The first alpha release will happen once the examples have been updated.

I'll take some (if not all) examples on me. Feel free to ping me on Gitter, merge request incoming.

Loading

@archseer
Copy link

@archseer archseer commented Jul 9, 2019

Note: while the tokio-threadpool crate was updated, the tokio crate itself is currently hardcoded to current_thread runtime. We should probably open an issue for that.

I tried porting the required modules but couldn't quite figure out what the updated code should look like.

Loading

@carllerche
Copy link
Member Author

@carllerche carllerche commented Jul 9, 2019

@archseer good call.

Loading

@CryZe
Copy link

@CryZe CryZe commented Jul 9, 2019

Is there a reason AsyncRead and AsyncWrite are not just reexported from futures? These are causing incompatibility problems for me. If it's not intentional, I'll send a PR.

Loading

@seanmonstar
Copy link
Member

@seanmonstar seanmonstar commented Jul 9, 2019

@CryZe so far, that's been intentional. There's been desire to explore alternate method signatures.

What compatibility issues are there? With other libraries?

Loading

@carllerche
Copy link
Member Author

@carllerche carllerche commented Jul 10, 2019

@archseer bringing back the multi-threaded runtime: #1280

Loading

@archseer
Copy link

@archseer archseer commented Jul 11, 2019

Thanks! With this I can now almost get things running (still tackling compat stuff). What I did notice though is that tokio-uds pulls in the tokio v0.1 crates because the dependency on it in tokio doesn't specify path ="../tokio-uds" I think:

https://github.com/tokio-rs/tokio/blob/master/tokio/Cargo.toml#L87

Loading

@rubdos
Copy link
Contributor

@rubdos rubdos commented Jul 11, 2019

FYI, proxy example at 914038e (rubdos/tokio/proxy-example) works now (with async fn accept()), but needs futures-preview. Feel free to pick that from my fork.

EDIT: accidentally pasted wrong commit. EDIT EDIT: accidentally thought to have pasted the wrong commit.

Loading

@rubdos
Copy link
Contributor

@rubdos rubdos commented Jul 11, 2019

Seems like all other examples depend on some decision like #1225, since some kind of Stream trait is basically required for nice async examples.

Loading

@alex
Copy link
Contributor

@alex alex commented Jul 21, 2019

Should tokio-tls be checked off? The issue it points at was resolved.

Loading

@carllerche
Copy link
Member Author

@carllerche carllerche commented Jul 21, 2019

@alex thanks 👍

Loading

@MOZGIII
Copy link
Contributor

@MOZGIII MOZGIII commented Jul 23, 2019

I've implemented a crate using futures-preview and now I'm trying to use it in my project with a master branch of tokio.

I'm getting this error:

error[E0277]: the trait bound `tokio_tcp::stream::TcpStream: futures_io::if_std::AsyncRead` is not satisfied

At this point, I know what's causing it, and that there is a workaround available to make tokio and futures-preview play nicely together (thanks to good people at rust's discord). I just wanted to share my current experience here, as well as the found workaround.

Loading

@osa1
Copy link
Contributor

@osa1 osa1 commented Jul 28, 2019

I think "chat", "udp-codec" and "tinydb" examples can be checked off as well.

Loading

@LucioFranco
Copy link
Member

@LucioFranco LucioFranco commented Jul 29, 2019

@osa1 thanks, its done!

An update, I think we want to get all the examples updated and do a final pass of the crates then we can start publishing alphas!

Loading

@Proximyst
Copy link

@Proximyst Proximyst commented Jul 30, 2019

You forgot the TCP echo on the examples list :)

Loading

@rrichardson
Copy link
Contributor

@rrichardson rrichardson commented Aug 2, 2019

@seanmonstar wrote:

so far, that's been intentional. There's been desire to explore alternate method signatures.
What compatibility issues are there? With other libraries?

I might be missing something obvious, but it is awkward to use tokio::TcpStream and friends which implements tokio::AsyncRead/Write and reconcile that with much of the Futures API which expects its own AsyncRead/Write.

Is there an alternative to TcpStream that implements futures::Async* ?

Loading

@agausmann
Copy link

@agausmann agausmann commented Aug 2, 2019

I'm working on reimplementing blocking example, and I discovered that tokio_threadpool::blocking returns a Poll. This is not very ergonomic in the current state of futures; I would likely have to use something like futures::poll_fn if one exists, or write my own future wrapping it. Is that something that we would want to turn into an async fn?

Loading

@LucioFranco
Copy link
Member

@LucioFranco LucioFranco commented Aug 2, 2019

@rrichardson you can use this compat layer for now https://github.com/nemo157/futures-tokio-compat/ we are still exploring the API a bit and the one in the futures crate isn't stable either.

@agausmann I believe we've been using https://github.com/tokio-rs/async/blob/master/async-util/src/future/poll_fn.rs#L34 but there is also https://docs.rs/futures-preview/0.3.0-alpha.17/futures/future/fn.poll_fn.html

Loading

Kobzol added a commit to Kobzol/tokio that referenced this issue Aug 14, 2019
This PR fixes the print each packet example in tokio.

Refs: tokio-rs#1201
Kobzol added a commit to Kobzol/tokio that referenced this issue Aug 15, 2019
This PR fixes the print each packet example in tokio.

Refs: tokio-rs#1201
carllerche added a commit that referenced this issue Aug 15, 2019
This PR fixes the print each packet example in tokio.

Refs: #1201
@carllerche
Copy link
Member Author

@carllerche carllerche commented Aug 26, 2019

This was done! 🎉

Loading

@carllerche carllerche closed this Aug 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet