pool

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPoolExhausted = errors.New("pool exhausted")

ErrPoolExhausted is returned if a pool cannot provide the request bytes.

Functions

This section is empty.

Types

type BucketedBytesPool added in v0.11.0

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

BucketedBytesPool is a bucketed pool for variably sized byte slices. It can be configured to not allow more than a maximum number of bytes being used at a given time. Every byte slice obtained from the pool must be returned.

func NewBucketedBytesPool added in v0.11.0

func NewBucketedBytesPool(minSize, maxSize int, factor float64, maxTotal uint64) (*BucketedBytesPool, error)

NewBytesPool returns a new BytesPool with size buckets for minSize to maxSize increasing by the given factor and maximum number of used bytes. No more than maxTotal bytes can be used at any given time unless maxTotal is set to 0.

func (*BucketedBytesPool) Get added in v0.11.0

func (p *BucketedBytesPool) Get(sz int) (*[]byte, error)

Get returns a new byte slices that fits the given size.

func (*BucketedBytesPool) Put added in v0.11.0

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

Put returns a byte slice to the right bucket in the pool.

type BytesPool

type BytesPool interface {
	Get(sz int) (*[]byte, error)
	Put(b *[]byte)
}

Jump to

Keyboard shortcuts

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