seaweedfs/weed/util/buffer_pool/sync_pool.go

21 lines
291 B
Go

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)
}