Merge branch 'master' into mq-subscribe

This commit is contained in:
chrislu
2024-04-11 19:48:00 -07:00
6 changed files with 51 additions and 18 deletions

View File

@@ -0,0 +1,20 @@
package buffer_pool
import (
"bytes"
"sync"
)
var syncPool = sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)
},
}
func SyncPoolGetBuffer() *bytes.Buffer {
return syncPool.Get().(*bytes.Buffer)
}
func SyncPoolPutBuffer(buffer *bytes.Buffer) {
syncPool.Put(buffer)
}