Repository navigation
Introduce stream::select_with_strategy - #2450
Merged
Merged
Conversation
The current select function only supports round robin. To change that would be a breaking change, so for now I propose a `select_bias` which takes a closure that defines the selection strategy. - When a breaking change is planned, we could re-consider this, but it does have 4 generic parameters of which one is a closure, compared to the 2 streams in `select`. - note the name select_bias. It's not consistent with `select_biased` used elsewhere in the lib. This can obviously be changed, but I feel the "ed" at the end does not add any semantic value but makes function names longer. - There isn't really integration tests included right now, but the examples in the docs get tested by doc test.
najamelan
force-pushed
the
feature/stream_select_bias
branch
from
June 8, 2021 16:38
6e4df4e to
b5bd8fe
Compare
taiki-e
reviewed
Jun 16, 2021
taiki-e
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR! The implementation looks good to me.
- I feel a name like
select_with_strategywould be more good because it is the user who decides whether this is biased or not. - Is it possible to use this as an internal implementation of
select? (without breaking change)
taiki-e
reviewed
Jun 16, 2021
taiki-e
reviewed
Jun 17, 2021
najamelan
force-pushed
the
feature/stream_select_bias
branch
from
June 17, 2021 06:47
55906db to
2df5523
Compare
taiki-e
reviewed
Jun 17, 2021
najamelan
force-pushed
the
feature/stream_select_bias
branch
from
June 17, 2021 07:20
2df5523 to
864c69a
Compare
This allows not to print the closure and give `Select` a derive impl.
The result for `Select` looks like:
`Select { inner: SelectWithStrategy { stream1: Fuse { stream: Repeat { item: 1 }, done: false }, stream2: Fuse { stream: Repeat { item: 2 }, done: false } } }`
najamelan
force-pushed
the
feature/stream_select_bias
branch
from
June 17, 2021 07:26
864c69a to
e8a17f9
Compare
pickfire
reviewed
Jun 28, 2021
| #[pin] | ||
| stream2: Fuse<St2>, | ||
| state: State, | ||
| clos: Clos, |
Contributor
There was a problem hiding this comment.
Is this a typo for close?
Contributor
Author
There was a problem hiding this comment.
It's the generic representing the closure. So not a typo. Of course another name can be chosen. I don't really care about what it's called.
taiki-e
pushed a commit
that referenced
this pull request
Jul 23, 2021
Merged
taiki-e
pushed a commit
that referenced
this pull request
Jul 23, 2021
Merged
Member
|
Published in 0.3.16. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current stream::select function only supports round robin. To change that
would be a breaking change, so for now I propose a
select_biaswhichtakes a closure that defines the selection strategy.
does have 4 generic parameters of which one is a closure, compared to
the 2 streams in
select. We could also reimplementselecton top of this,we just need to deal with hiding the generics of the closure, but I reckon a
function pointer can be named and we don't need to capture anything....
select_biasedusedelsewhere in the lib. This can obviously be changed, but I feel the "ed"
at the end does not add any semantic value but makes function names
longer.
in the docs get tested by doc test.