Skip to content

Stream select macro - #2262

Merged
taiki-e merged 10 commits into
rust-lang:masterfrom
Xaeroxe:stream-select
Jul 31, 2021
Merged

taiki-e merged 10 commits into
rust-lang:masterfrom
Xaeroxe:stream-select

Conversation

@Xaeroxe

@Xaeroxe Xaeroxe commented Nov 13, 2020 •

Copy link
Copy Markdown
Contributor

Adds a new procedural macro to the futures crate that I've found some use for. stream_select! works similarly to the select_all function, but doesn't require the streams to all be the same type. Nor does it use a Box<dyn Stream> to accomplish that. It's implemented in terms of the select! macro , but represents a type rather than multiple branches of execution. In my use case I would feed the stream from stream_select! into a select! statement, as many of the streams I want to select! over should be treated identically in the select! statement.

Reviewers may ask "Why not just use the select function repeatedly?" And the answer to that is that recursive use of the select function results in an unfair stream, with priority being given to streams on the upper layers.

@taiki-e taiki-e left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and sorry for the late review!

I think it makes sense to add a feature like this (this is actually a stream version of simple select), but I don't want to add features that rely on Fused{Future,Stream} because Fused{Future,Stream} will be removed in the next major version.

@taiki-e taiki-e added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author label Jun 16, 2021
@Xaeroxe

Xaeroxe commented Jun 23, 2021

Copy link
Copy Markdown
Contributor Author

@taiki-e I've removed the FusedStream dependency, this is now ready for review.

@taiki-e taiki-e removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author label Jun 24, 2021
@taiki-e
taiki-e self-requested a review June 24, 2021 14:38

@taiki-e taiki-e left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl LGTM. Sorry for the late review!

Comment thread futures/tests/macro-tests/src/main.rs Outdated
Comment thread futures-macro/src/stream_select.rs Outdated
@Xaeroxe

Xaeroxe commented Jul 30, 2021

Copy link
Copy Markdown
Contributor Author

@taiki-e ready for re-review, thank you!

Comment thread futures/tests/async_await_macros.rs Outdated

@taiki-e taiki-e left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @Xaeroxe!

@taiki-e
taiki-e merged commit 633a905 into rust-lang:master Jul 31, 2021
@taiki-e taiki-e added the 0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. label Jul 31, 2021
taiki-e pushed a commit that referenced this pull request Aug 28, 2021
@taiki-e taiki-e mentioned this pull request Aug 28, 2021
@taiki-e taiki-e added 0.3-backport: completed and removed 0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. labels Aug 28, 2021
taiki-e pushed a commit that referenced this pull request Aug 30, 2021
@taiki-e taiki-e mentioned this pull request Aug 30, 2021
@taiki-e

taiki-e commented Aug 30, 2021

Copy link
Copy Markdown
Member

Published in 0.3.17

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants