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

codec: Add Framed::with_capacity #2215

Merged
merged 1 commit into from
Mar 2, 2020
Merged

Conversation

stammw
Copy link
Contributor

@stammw stammw commented Feb 4, 2020

FramedRead users may want to set it's internal buffer size to minimize the chances of it being reallocated.

In a variety of cases, it is possible to make a good guess on the frame size. Let this be configured instead of sticking with framed_read::INITIAL_CAPACITY of 8k.

Relates to #2156.

@craftytrickster
Copy link
Contributor

If you are using Framed::new() in order to construct your frame from an AsyncRead + AsyncWrite item, would it be possible to also have this capacity?

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@LucioFranco
Copy link
Member

Actually, one more thing, would it make sense to add this API to Framed as well?

@stammw
Copy link
Contributor Author

stammw commented Mar 2, 2020

Got Framed::with_capacity() rebased into the only commit. Thanks for the suggestion!

@LucioFranco LucioFranco changed the title Let user create new FramedRead with custom initial capacity codec: Add Framed::with_capacity Mar 2, 2020
@LucioFranco LucioFranco merged commit 1eb6131 into tokio-rs:master Mar 2, 2020
sthagen added a commit to sthagen/tokio-rs-tokio that referenced this pull request Mar 2, 2020
codec: Add `Framed::with_capacity` (tokio-rs#2215)
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

3 participants