lostluck commented on issue #25522: URL: https://github.com/apache/beam/issues/25522#issuecomment-1448345949
Please look at the linked code from the slog package from the start of the issue. There's no need to wrap in a struct, and the type can self return to the pool via a method call. On Tue, Feb 28, 2023, 6:47 AM Junhao Liu ***@***.***> wrote: > I came across a solution to this, but I don't know whether my > understanding is accurate. Could u please help me to review it and give > some comments and suggestions? Thanks! > > 1. Create a package named "buffer". This package will contain the > implementation of the allocated buffer by sync.Pool. > 2. Define a struct named Buffer in the "buffer" package that wraps a > []byte slice. > 3. Implement a "GetBuffer" function in the "buffer" package that > returns a new instance of the Buffer struct from the sync.Pool, and a > "PutBuffer" function in the "buffer" package that returns a used Buffer > struct back to the sync.Pool. > 4. Replace all small []byte or bytes.Buffer uses in go sdk with calls > to "GetBuffer" and "PutBuffer". > > — > Reply to this email directly, view it on GitHub > <https://github.com/apache/beam/issues/25522#issuecomment-1448313105>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ADKDOFIJRU7CAHEGHVWAQVLWZYFYBANCNFSM6AAAAAAU64XZNE> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> > -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
