vendor: update all dependencies to latest versions
This commit is contained in:
parent
8e83fb6fb9
commit
7d3a17725d
4878 changed files with 1974229 additions and 201215 deletions
39
vendor/github.com/pengsrc/go-shared/buffer/bytes_pool.go
generated
vendored
Normal file
39
vendor/github.com/pengsrc/go-shared/buffer/bytes_pool.go
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
package buffer
|
||||
|
||||
import "sync"
|
||||
|
||||
// A BytesBufferPool is a type-safe wrapper around a sync.BytesBufferPool.
|
||||
type BytesBufferPool struct {
|
||||
p *sync.Pool
|
||||
}
|
||||
|
||||
// NewBytesPool constructs a new BytesBufferPool.
|
||||
func NewBytesPool() BytesBufferPool {
|
||||
return BytesBufferPool{
|
||||
p: &sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &BytesBuffer{bs: make([]byte, 0, defaultSize)}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Get retrieves a BytesBuffer from the pool, creating one if necessary.
|
||||
func (p BytesBufferPool) Get() *BytesBuffer {
|
||||
buf := p.p.Get().(*BytesBuffer)
|
||||
buf.Reset()
|
||||
buf.pool = p
|
||||
return buf
|
||||
}
|
||||
|
||||
func (p BytesBufferPool) put(buf *BytesBuffer) {
|
||||
p.p.Put(buf)
|
||||
}
|
||||
|
||||
// GlobalBytesPool returns the global buffer pool.
|
||||
func GlobalBytesPool() *BytesBufferPool {
|
||||
return &bytesPool
|
||||
}
|
||||
|
||||
// bytesPool is a pool of buffer bytes.
|
||||
var bytesPool = NewBytesPool()
|
Loading…
Add table
Add a link
Reference in a new issue