mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-23 00:27:55 +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)
|
||
|
}
|