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