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

feat: add buffered writer #9

Merged
merged 2 commits into from May 21, 2019
Merged

feat: add buffered writer #9

merged 2 commits into from May 21, 2019

Conversation

Stebalien
Copy link
Member

We need this in both yamux and msgio.

Copy link

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

Shouldn't we have a constructor for the writer? Or is the user expected to directly instantiate and initialize W?


// Writer is a buffered writer that returns its internal buffer in a pool when
// not in use.
type Writer struct {
Copy link

Choose a reason for hiding this comment

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

don't we also need a constructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really, I'm treating this like https://golang.org/pkg/io/#LimitedReader. Although, that will make it a bit tricky to introduce different sized buffers. I don't have strong opinions on this (my main goal was to avoid an allocation.

Copy link

Choose a reason for hiding this comment

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

ok, fair enough.

@Stebalien Stebalien merged commit c4a5988 into master May 21, 2019
@Stebalien Stebalien deleted the feat/bufw branch May 21, 2019 20:27
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