pool

package module
v0.0.0-...-019d002 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

README

Byte buffer pool

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPoolLimitReached = errors.New("pool limit reached")
	ErrNilBuffer        = errors.New("cannot put nil-buffer into pool")
	ErrNoPoolBuffer     = errors.New("buffer was not taken from pool")
)

Some errors returned by the Put method.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Used  int
	Count int
}

Entry defines a usage entry.

type Pool

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

Pool deinfes the byte buffer pool.

func New

func New(l uint64) *Pool

New returns a new bytes buffer pool with the provided size limit.

func (*Pool) Get

func (p *Pool) Get(size uint64) ([]byte, error)

Get returns a buffer of the provided size.

func (*Pool) Put

func (p *Pool) Put(buffer []byte) error

Put places the provided buffer back in the pool.

func (*Pool) Size

func (p *Pool) Size() uint64

Size returns the size of the byte buffer pool.

func (*Pool) Usage

func (p *Pool) Usage() Usage

Usage returns a map with counts of all sizes.

type Usage

type Usage map[uint64]Entry

Usage defines a container map where usage information about the buffer usage is stored.

Jump to

Keyboard shortcuts

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