Handle buffer pool for oxy

This commit is contained in:
SALLEYRON Julien 2018-06-07 09:46:03 +02:00 committed by Traefiker Bot
parent 446d73fcf5
commit 62ded580ce
4 changed files with 44 additions and 1 deletions

27
server/bufferpool.go Normal file
View file

@ -0,0 +1,27 @@
package server
import "sync"
const bufferPoolSize int = 32 * 1024
func newBufferPool() *bufferPool {
return &bufferPool{
pool: sync.Pool{
New: func() interface{} {
return make([]byte, bufferPoolSize)
},
},
}
}
type bufferPool struct {
pool sync.Pool
}
func (b *bufferPool) Get() []byte {
return b.pool.Get().([]byte)
}
func (b *bufferPool) Put(bytes []byte) {
b.pool.Put(bytes)
}