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 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 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.

@archseer
Copy link

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.

@carllerche
Copy link
Member Author

@archseer good call.

@CryZe
Copy link

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.

@seanmonstar
Copy link
Member

@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
Copy link
Member Author

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

@archseer
Copy link

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
Copy link
Contributor

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.

@rubdos
Copy link
Contributor

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.

@alex
Copy link
Contributor

alex commented Jul 21, 2019

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

@carllerche
Copy link
Member Author

@alex thanks 👍

@MOZGIII
Copy link
Contributor

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.

@osa1
Copy link
Contributor

osa1 commented Jul 28, 2019

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

@LucioFranco
Copy link
Member

@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
Copy link

You forgot the TCP echo on the examples list :)

@rrichardson
Copy link
Contributor

@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
Copy link

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
Copy link
Member

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

This was done! 🎉

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

No branches or pull requests