1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00
v2fly/common/buf/buffer_pool.go
2018-03-11 23:06:04 +01:00

33 lines
458 B
Go

package buf
import (
"sync"
)
const (
// Size of a regular buffer.
Size = 2 * 1024
)
func createAllocFunc(size uint32) func() interface{} {
return func() interface{} {
return make([]byte, size)
}
}
var pool2k = &sync.Pool{
New: createAllocFunc(2 * 1024),
}
var pool8k = &sync.Pool{
New: createAllocFunc(8 * 1024),
}
var pool64k = &sync.Pool{
New: createAllocFunc(64 * 1024),
}
var pool128k = &sync.Pool{
New: createAllocFunc(128 * 1024),
}