impl Future for stream::{Buffered, BufferUnordered, FuturesOrdered}#2677
Open
arcnmx wants to merge 2 commits intorust-lang:masterfrom
Open
impl Future for stream::{Buffered, BufferUnordered, FuturesOrdered}#2677arcnmx wants to merge 2 commits intorust-lang:masterfrom
arcnmx wants to merge 2 commits intorust-lang:masterfrom
Conversation
This enables `poll()`ing to fill the buffer without producing or consuming the Stream's outputs.
3ffd896 to
94b6155
Compare
Member
|
Thanks for the PR. What is the use case for these methods? |
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.
This enables
poll()ing to fill the buffer without producing or consuming the Stream's outputs.BufferedandFuturesOrderedwill also poll their inner futures produced by the stream, since they have an output value buffer available.BufferUnorderedhowever will only poll the underlying stream, as it cannot produce outputs without consuming them.Given that theOutputof theBufferUnorderedimpl isn't particularly useful (because it doesn't indicate anything about the futures produced by the stream), maybe it should betype Output = Infallible, and never complete?For the other two, the completion is more meaningful as it indicates that the stream is empty and that all captured futures have produced outputs (though in the case of
Buffered, it will stall while the buffer remains full).It may also make sense to expose this as apoll_stream()function rather thanimpl Future(or otherwise aIntoFuture for &Selfor something), for the sake of extension trait method resolution.EDIT: moved to inherent
poll_stream()instead, see latest commit. Final name tbd (buffered.poll_all()?poll_buffer()?poll_fill()?)