Skip to content
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

impl Future for stream::{Buffered, BufferUnordered, FuturesOrdered} #2677

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arcnmx
Copy link
Contributor

@arcnmx arcnmx commented Dec 18, 2022

This enables poll()ing to fill the buffer without producing or consuming the Stream's outputs.

Buffered and FuturesOrdered will also poll their inner futures produced by the stream, since they have an output value buffer available.
BufferUnordered however will only poll the underlying stream, as it cannot produce outputs without consuming them.

Given that the Output of the BufferUnordered impl isn't particularly useful (because it doesn't indicate anything about the futures produced by the stream), maybe it should be type 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 a poll_stream() function rather than impl Future (or otherwise a IntoFuture for &Self or 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()?)

This enables `poll()`ing to fill the buffer without producing or
consuming the Stream's outputs.
@arcnmx arcnmx requested a review from taiki-e as a code owner December 18, 2022 20:25
@taiki-e
Copy link
Member

taiki-e commented Mar 5, 2023

Thanks for the PR. What is the use case for these methods?

@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 Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants