bytespool

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesPool

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

func NewBytesPool

func NewBytesPool(poolSize int, bytesLength int) *BytesPool

poolSize is the maximum number of elements can be stored in pool bytesLength is the size of byte array, like cap([]byte{})

func (*BytesPool) Allocations

func (a *BytesPool) Allocations() uint64

func (*BytesPool) BytesLen

func (a *BytesPool) BytesLen() int

func (*BytesPool) Get

func (a *BytesPool) Get() []byte

Returns bytes from pool. If pool is empty or no free bytes available new bytes will be allocated. Notice, there is no memory zeroing or cleanup is made, bytes returns as they are

func (*BytesPool) Put

func (a *BytesPool) Put(bts []byte)

Put bytes back to the pool. If the length of provided bytes not equal defined, just ignore them.

type NoOpBytesPool

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

func NewNoOpBytesPool

func NewNoOpBytesPool(bytesLength int) *NoOpBytesPool

poolSize is the maximum number of elements can be stored in pool bytesLength is the size of byte array, like cap([]byte{})

func (*NoOpBytesPool) BytesLen

func (a *NoOpBytesPool) BytesLen() int

func (*NoOpBytesPool) Get

func (a *NoOpBytesPool) Get() []byte

func (*NoOpBytesPool) Put

func (a *NoOpBytesPool) Put([]byte)

type Pool

type Pool interface {
	Get() []byte
	Put([]byte)
	BytesLen() int
}

type Stats

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

func NewStats

func NewStats(pool *BytesPool) *Stats

func (*Stats) BytesLen

func (a *Stats) BytesLen() int

func (*Stats) Get

func (a *Stats) Get() []byte

func (*Stats) Put

func (a *Stats) Put(bts []byte)

func (*Stats) Stat

func (a *Stats) Stat() (allocations, puts, gets uint64)

Jump to

Keyboard shortcuts

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