mirror of
https://github.com/criyle/go-sandbox.git
synced 2025-11-04 14:49:53 +08:00
25 lines
358 B
Go
25 lines
358 B
Go
package deamon
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// 16k buffsize
|
|
const bufferSize = 16384
|
|
|
|
var bufferPool = sync.Pool{
|
|
New: func() interface{} {
|
|
return make([]byte, bufferSize)
|
|
},
|
|
}
|
|
|
|
// GetBuffer get buffer from pool
|
|
func GetBuffer() []byte {
|
|
return bufferPool.Get().([]byte)
|
|
}
|
|
|
|
// PutBuffer return buffer to the pool
|
|
func PutBuffer(x []byte) {
|
|
bufferPool.Put(x)
|
|
}
|