Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool buffer pool definition
func NewBufferPool ¶
func NewBufferPool(alloc int) *BufferPool
NewBufferPool creates a new BufferPool bounded to the given buffer size.
func (*BufferPool) Get ¶
func (bp *BufferPool) Get() *bytes.Buffer
Get gets a Buffer from the BufferPool
func (*BufferPool) Put ¶
func (bp *BufferPool) Put(buffer *bytes.Buffer)
Put returns the given Buffer to the BufferPool
type SizedBufferPool ¶
type SizedBufferPool struct {
// contains filtered or unexported fields
}
SizedBufferPool sized buffer pool definition
func NewSizedBufferPool ¶
func NewSizedBufferPool(size int, alloc int) (bp *SizedBufferPool)
SizedBufferPool creates a new BufferPool bounded to the given size. size defines the number of buffers to be retained in the pool and alloc sets the initial capacity of new buffers to minimize calls to make().
The value of alloc should seek to provide a buffer that is representative of most data written to the the buffer (i.e. 95th percentile) without being overly large (which will increase static memory consumption).
func (*SizedBufferPool) Get ¶
func (bp *SizedBufferPool) Get() (b *bytes.Buffer)
Get gets a Buffer from the SizedBufferPool, or creates a new one if none are available in the pool. Buffers have a pre-allocated capacity.
func (*SizedBufferPool) Put ¶
func (bp *SizedBufferPool) Put(b *bytes.Buffer)
Put returns the given Buffer to the SizedBufferPool.