mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-27 20:59:42 +08:00
21 lines
291 B
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)
|
|
}
|