File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,8 @@ func (p *bufferPoolImpl) GetBuffer(initSize int) Buffer {
118118
119119func (p * bufferPoolImpl ) Put (buf Buffer ) {
120120 if b , ok := buf .(* buffer ); ok {
121- // Get the callback before putting back to the pool because it might be reset
121+ // Get the callback before putting back to the pool because it might be reset after the
122+ // buffer is returned to the pool and reused in GetBuffer.
122123 cb := b .releaseCallback
123124 p .Pool .Put (b )
124125 if cb != nil {
@@ -133,8 +134,12 @@ type buffer struct {
133134 readerIdx uint32
134135 writerIdx uint32
135136
136- refCnt atomic.Int64
137- pool BuffersPool
137+ refCnt atomic.Int64
138+ pool BuffersPool
139+
140+ // releaseCallback is an optional function that is called when the buffer is released back to the pool.
141+ // It allows custom cleanup or notification logic to be executed after the buffer is returned.
142+ // The callback is invoked in bufferPoolImpl.Put, after the buffer is put back into the pool.
138143 releaseCallback func ()
139144}
140145
You can’t perform that action at this time.
0 commit comments