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

Introduce ready_chunks adaptor #2123

Merged
merged 1 commit into from Apr 22, 2020
Merged

Conversation

glebpom
Copy link
Contributor

@glebpom glebpom commented Apr 10, 2020

This is the implementation of ready_chunks adapter. It is similar to chunks, but collects the data while the underlying stream returns Poll::Ready. Otherwise, the collected vector immediately returns so that the stream never blocks. The motivation behind it is that often we need to group multiple elements from the stream (specifically mpsc channels) and send them in a single system call. For example, it may be usable with calls like sendmmsg or UDP GSO

@cramertj
Copy link
Member

This looks great to me, thanks!

@cramertj
Copy link
Member

cramertj commented Apr 22, 2020

This looks great to me, thanks! I'd also be interested in a stream.read_next_ready_chunk(&mut buffer) or similar that would read chunks into a preallocated vector to avoid the repeated heap allocations every time.

@cramertj cramertj merged commit 94b894a into rust-lang:master Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants