-
Notifications
You must be signed in to change notification settings - Fork 325
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
s2: Proposal: Callback when done with EncodeBuffer #981
Comments
Seems feasible. |
klauspost
added a commit
that referenced
this issue
Jul 26, 2024
WriterBufferDone will perform a callback when EncodeBuffer has finished writing a buffer to the output and the buffer can safely be reused. If the buffer was split into several blocks, it will be sent after the last block. Callbacks will not be done concurrently. Fixes #981
See #842 |
Nice, thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Buffers given to s2.Writer.EncodeBuffer() can't be touched until a full Flush/Close is done, while the buffer is probably reusable much sooner.
What would you think of a WriterOption that installs a callback that is invoked whenever it is safe to reuse the buffer given to EncodeBuffer?
I'm thinking
func WriterEncodeBufferCallback(callback func([]byte)) WriterOption
.The common use case would be to return the buffer to a sync.Pool. I want to pass data straight from a ringbuffer-of-bytes into EncodeBuffer and want to know when I can mark it as freed.
I'll be happy to write up the PR if you agree with this proposal.
The text was updated successfully, but these errors were encountered: