mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-05-11 03:16:34 +00:00

- Move packages the provide generic functionality (such as config) from `cmd` subtree to top level. - Remove all dependencies on `cmd` subtree from top level packages. - Consolidate all code dealing with token generation and transfer to a single cohesive package.
30 lines
481 B
Go
30 lines
481 B
Go
package origin
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
type bufferPool struct {
|
|
// A bufferPool must not be copied after first use.
|
|
// https://golang.org/pkg/sync/#Pool
|
|
buffers sync.Pool
|
|
}
|
|
|
|
func newBufferPool(bufferSize int) *bufferPool {
|
|
return &bufferPool{
|
|
buffers: sync.Pool{
|
|
New: func() interface{} {
|
|
return make([]byte, bufferSize)
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func (p *bufferPool) Get() []byte {
|
|
return p.buffers.Get().([]byte)
|
|
}
|
|
|
|
func (p *bufferPool) Put(buf []byte) {
|
|
p.buffers.Put(buf)
|
|
}
|