-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Implement core::future::join!
#91645
Conversation
r? @yaahc (rust-highfive has picked a reviewer for you, use r? to override) |
035dfd2
to
e356ce3
Compare
This comment has been minimized.
This comment has been minimized.
e356ce3
to
d07cef2
Compare
I've seen multiple people observe, in various different contexts, that That would also make it equivalent to the Similarly, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
354a2b1
to
5478f43
Compare
Since this is unstable and feature-gated, I'm going to go ahead and r+ it. @bors r+ |
📌 Commit 5478f43 has been approved by |
…askrgr Rollup of 5 pull requests Successful merges: - rust-lang#91042 (Use Vec extend instead of repeated pushes on several places) - rust-lang#91476 (Improve 'cannot contain emoji' error.) - rust-lang#91568 (Pretty print break and continue without redundant space) - rust-lang#91645 (Implement `core::future::join!`) - rust-lang#91666 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This is a follow-up from rust-lang#91645, regarding [some remarks I made](https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/join!/near/264293660). Mainly: - it hides the recursive munching through a private `macro`, to avoid leaking such details (a corollary is getting rid of the need to use `@` to disambiguate); - it uses a `match` binding, _outside_ the `async move` block, to better match the semantics from function-like syntax; - it pre-pins the future before calling into `poll_fn`, since `poll_fn`, alone, cannot guarantee that its capture does not move; - it uses `.ready()?` since it's such a neat pattern; - it renames `Took` to `Taken` for consistency with `Done`.
…triplett Minor improvements to `future::join!`'s implementation This is a follow-up from rust-lang#91645, regarding [some remarks I made](https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-async-foundations/topic/join!/near/264293660). Mainly: - it hides the recursive munching through a private `macro`, to avoid leaking such details (a corollary is getting rid of the need to use ``@`` to disambiguate); - it uses a `match` binding, _outside_ the `async move` block, to better match the semantics from function-like syntax; - it pre-pins the future before calling into `poll_fn`, since `poll_fn`, alone, cannot guarantee that its capture does not move (to clarify: I believe the previous code was sound, thanks to the outer layer of `async`. But I find it clearer / more robust to refactorings this way 🙂). - it uses `@ibraheemdev's` very neat `.ready()?`; - it renames `Took` to `Taken` for consistency with `Done` (tiny nit 😄). ~~TODO~~Done: - [x] Add unit tests to enforce the function-like `:value` semantics are respected. r? `@nrc`
Note: the @rust-lang/wg-async-foundations working group was not notified of this change prior to merging. The link in the opening post did not resolve, and notifications were not sent. I would've liked to have a chance to comment on this design, as I think it is part of a larger topic of async concurrency which warrants an RFC, and should not be merged into the stdlib in a piece-meal fashion. |
I do want to note that the reason this didn't get an RFC is because the libs team changed the requirements for adding new features and when they need RFCs in an attempt to ease the contribution experience and make it easier to experiment with new APIs. Us approving a nightly only API is in no way an endorsement that we believe a change should be stabilized, and there is still plenty of time to comment on the design. While I agree that this change and the associated story likely warrant an RFC I want to be careful that we don't overcorrect and institute process changes as a result. |
Ah, thanks for clarifying. I was not aware the policy had changed. |
join!
polls multiple futures concurrently and returns their outputs.cc @rust-lang/wg-async-foundations