Delete buffer_pool.go

This commit is contained in:
Jason
2019-08-12 14:28:39 +08:00
parent 97c71dd9a9
commit 51e02d0236

View File

@@ -1,35 +0,0 @@
package core
import (
"sync"
)
var pool *sync.Pool
const BufSize = 32 * 1024
func SetBufferPool(p *sync.Pool) {
pool = p
}
func NewBytes(size int) []byte {
if size <= BufSize {
return pool.Get().([]byte)
} else {
return make([]byte, size)
}
}
func FreeBytes(b []byte) {
if len(b) >= BufSize {
pool.Put(b)
}
}
func init() {
SetBufferPool(&sync.Pool{
New: func() interface{} {
return make([]byte, BufSize)
},
})
}