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

Open
carllerche opened this issue Jun 26, 2019 · 18 comments

Comments

@carllerche
Copy link
Member

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.

@carllerche carllerche added this to the v0.2 milestone Jun 26, 2019

@carllerche carllerche referenced this issue Jun 26, 2019
1 of 4 tasks complete

@carllerche carllerche added the meta label Jun 26, 2019

@rubdos

This comment has been minimized.

Copy link
Contributor

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.

@Ereski Ereski referenced this issue Jul 5, 2019
0 of 1 task complete
@archseer

This comment has been minimized.

Copy link

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.

@carllerche

This comment has been minimized.

Copy link
Member Author

commented Jul 9, 2019

@archseer good call.

@CryZe

This comment has been minimized.

Copy link

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.

@seanmonstar

This comment has been minimized.

Copy link
Member

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?

@carllerche

This comment has been minimized.

Copy link
Member Author

commented Jul 10, 2019

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

@archseer

This comment has been minimized.

Copy link

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

@rubdos

This comment has been minimized.

Copy link
Contributor

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.

@rubdos

This comment has been minimized.

Copy link
Contributor

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.

@alex

This comment has been minimized.

Copy link
Contributor

commented Jul 21, 2019

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

@carllerche

This comment has been minimized.

Copy link
Member Author

commented Jul 21, 2019

@alex thanks 👍

@MOZGIII

This comment has been minimized.

Copy link
Contributor

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.

@osa1

This comment has been minimized.

Copy link

commented Jul 28, 2019

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

@LucioFranco

This comment has been minimized.

Copy link
Member

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!

@Proximyst

This comment has been minimized.

Copy link

commented Jul 30, 2019

You forgot the TCP echo on the examples list :)

@rrichardson

This comment has been minimized.

Copy link
Contributor

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

@AGausmann

This comment has been minimized.

Copy link

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?

@LucioFranco

This comment has been minimized.

Copy link
Member

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

Kobzol added a commit to Kobzol/tokio that referenced this issue Aug 14, 2019

tokio: rewrite print_each_packet example using async/await
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

tokio: rewrite print_each_packet example using async/await
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

tokio: rewrite print_each_packet example using async/await (#1446)
This PR fixes the print each packet example in tokio.

Refs: #1201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.