Tokio: meta: update to std::future and release an alpha.

Created on 26 Jun 2019  路  19Comments  路  Source: tokio-rs/tokio

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

Crates to update

  • [x] tokio-codec (#1189).
  • [x] tokio-fs (#1192).
  • [x] tokio-signal (#1193).
  • [x] tokio-threadpool (#1200).
  • [x] tokio-tls (#1194).
  • [x] tokio-udp (#1195).
  • [x] tokio-uds (#1196).

Examples

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

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

Additional functionality

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

  • [x] I/O helpers (#1203).

Alpha release

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

Most helpful comment

This was done! 馃帀

All 19 comments

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.

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.

@archseer good call.

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.

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

What compatibility issues are there? With other libraries?

@archseer bringing back the multi-threaded runtime: https://github.com/tokio-rs/tokio/pull/1280

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

FYI, proxy example at 914038e45e54e053daf9fdb55c40aa600eb2e3da (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.

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

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

@alex thanks :+1:

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.

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

@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!

You forgot the TCP echo on the examples list :)

@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* ?

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?

@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

This was done! 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidbarsky picture davidbarsky  路  3Comments

peterhuene picture peterhuene  路  4Comments

ancwrd1 picture ancwrd1  路  5Comments

carllerche picture carllerche  路  3Comments

heretic13 picture heretic13  路  3Comments