traefik/server/bufferpool.go

28 lines
401 B
Go
Raw Normal View History

2018-06-07 07:46:03 +00:00
package server
import "sync"
2018-06-11 09:36:03 +00:00
const bufferPoolSize = 32 * 1024
2018-06-07 07:46:03 +00:00
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)
}