traefik/server/service/bufferpool.go

28 lines
402 B
Go
Raw Normal View History

2018-11-14 09:18:03 +00:00
package service
2018-06-07 07:46:03 +00:00
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)
}