Skip to content

Updating to std::future::Future #1805

Description

@seanmonstar

With std::future::Future stabilizing in Rust 1.36, it is a goal to upgrade from futures@0.1 to std::future::Future in the next breaking change (hyper@0.13).


Status:

Activity

  1. added
    B-upstreamBlocked: needs a change in a dependency or the compiler.
    C-featureCategory: feature. This is adding a new feature.
    E-hardEffort: hard. Likely requires a deeper understanding of how hyper's internals work.
    on Apr 30, 2019
  2. added this to the 0.13 milestone on Apr 30, 2019
  3. davidbarsky commented on Apr 30, 2019

    @davidbarsky
    Contributor

    I might be missing something, but is there a tracking issue on Tower to support 0.3 futures?

  4. dekellum commented on May 22, 2019

    @dekellum

    You say you are just considering it, but would TLS (Thread Local Storage, I presume) play well with Tokio's multi-threaded executor and, for example with conditional calls to tokio_threadpool::blocking in (Body) Streams and Sinks?

  5. seanmonstar commented on May 22, 2019

    @seanmonstar
    MemberAuthor

    That should be fine. When calling poll methods, we'd still need to materialize the Context before doing so, so there'd be no relying on other libraries keeping things on the same thread. It's more just wanting to reduce the noise of having to pass a Context to many methods of proto::h1::Conn that don't always need it, but might poll the IO.

  6. seanmonstar commented on Jun 11, 2019

    @seanmonstar
    MemberAuthor

    Most of the dependencies needed are updated in tokio's std-future branch. Disabling tokio-threadpool and h2 should hopefully be enough to start a branch here.

    It's probably not worth figuring out some TLS Context thingy, and just passing the argument everywhere.

  7. softprops commented on Jul 4, 2019

    @softprops
    Contributor
  8. seanmonstar commented on Jul 5, 2019

    @seanmonstar
    MemberAuthor

    #1836 is the PR for this, it's pretty close. Most things work (minus h2), and I have some local work to remove much of added unsafety, which I hope to have ready Monday. I'll likely merge that into master with docs and tests disabled, to allow those things to be worked on in parallel.

  9. seanmonstar commented on Jul 9, 2019

    @seanmonstar
    MemberAuthor

    Master is now tracking 0.13, and #1836 was merged into it. It lacks HTTP2 support, an unsafe pin audit, and all the tests and examples were disabled, but hopefully those can be worked on in parallel.

  10. jplatte commented on Jul 19, 2019

    @jplatte
    Contributor

    Thanks everyone for working on this! I'm a bit confused about one thing though - is the move to std::future::Future intentionally also a move to async / await? I was assuming I could build a library with MSRV 1.36 that's going to be using hyper 0.13, but a bunch of code has already been committed that relies on #![feature(async_await)] instead of only the Future trait. Is it just too much hassle to convert to the new Future first, and start using async / await later? (which should purely be an implementation detail)

  11. lnicola commented on Jul 19, 2019

    @lnicola
    Contributor

    tokio 0.2 uses await AFAIK.

  12. jplatte commented on Jul 19, 2019

    @jplatte
    Contributor

    Thanks. I asked on the tokio Gitter channel; apparently they want to only release 0.2 once async_await is stabilized.

  13. abonander commented on Aug 5, 2019

    @abonander
    Contributor

    @seanmonstar are there plans to migrate Body to AsyncRead instead of being a Stream<Item = Chunk>? If it uses AsyncRead I can add async implementations to multipart and abandon multipart-async. I'm wondering if I should maintain two different crates anyway as the ecosystem seems to be migrating wholesale to async.

  14. davidbarsky commented on Aug 5, 2019

    @davidbarsky
    Contributor

    @abonander Might be a tricky tricky to do so for a few reasons:

    • Body isn't really a Stream<Item = Chunk>, it's a Payload.
    • AsyncRead doesn't—to the best of my knowledge—have the equivalent of Payload::poll_trailers, which is needed H/2 connections. The closest thing seems to be http-body, but that isn't AsyncRead.

    Personally, I'd love to have a shared interface/trait at the moment for the reasons you outlined, but I'm not confident any of the shared interfaces—HttpBody or AsyncRead—tick off all the requirements someone might have. Maybe a blanket implementation for either trait could work/bridge some gaps in the interface?

  15. abonander commented on Aug 5, 2019

    @abonander
    Contributor

    @davidbarsky I mostly meant if there were plans to add the impl even though I used "instead of". I didn't mean removing any other API.

  16. davidbarsky commented on Aug 5, 2019

    @davidbarsky
    Contributor

    @abonander Ah, sorry about that; I misread what you said. Maybe? I'm not 100% sure how that could be implemented without needing specialization, but I might be missing something!

  17. abonander commented on Aug 6, 2019

    @abonander
    Contributor

    @davidbarsky how would specialization be necessary? There's only one possible impl, Body isn't generic. Digging through the code it looks like it uses AsyncRead underneath and then switches to producing Bytes in proto::h1::io.

  18. seanmonstar commented on Aug 14, 2019

    @seanmonstar
    MemberAuthor

    @abonander

    Are there plans to migrate Body to AsyncRead instead of being a Stream<Item = Chunk>?
    [..]
    I mostly meant if there were plans to add the impl even though I used "instead of". I didn't mean removing any other API.

    No plans so far... Here's some reasons of the top of my head why not to:

    1. The Body cannot freely implement Stream and AsyncRead. In order to provide AsyncRead, it would need to add a slot to cache a Chunk, in case the AsyncRead::poll_read buffer wasn't big enough to copy the full thing. This would make the struct bigger and add another branch to Stream::poll_next.
    2. The Stream impl can include more specific errors. I suppose an AsyncRead could just translate those to std::io::ErrorKind::Other, though...

    If there are good reasons to consider otherwise, we should open a new specific issue to discuss, ya?

  19. seanmonstar commented on Aug 19, 2019

    @seanmonstar
    MemberAuthor

    All the original "features" on master now use std::future, so I'm going to close this. Some tests and docs still need updating, thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-upstreamBlocked: needs a change in a dependency or the compiler.C-featureCategory: feature. This is adding a new feature.E-hardEffort: hard. Likely requires a deeper understanding of how hyper's internals work.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions