bucketpool

package
v3.0.0-rc.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool is actually multiple pools which store buffers of specific size. i.e. it can be three pools which return buffers 32K, 64K and 128K.

func New

func New(minSize, maxSize int) *Pool

New returns Pool which has buckets from minSize to maxSize. Buckets increase with the power of two, i.e with multiplier 2: [2b, 4b, 16b, ... , 1024b] Last pool will always be capped to maxSize.

func (*Pool) Get

func (p *Pool) Get(size int) *[]byte

Get returns pointer to []byte which has len size. If there is no bucket with buffers >= size, slice will be allocated.

func (*Pool) Put

func (p *Pool) Put(b *[]byte)

Put returns pointer to slice to some bucket. Discards slice for which there is no bucket

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL