data

package
v1.0.35 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxBytesLimit = errors.New("Max bytes limit of bytebufffer")
)

Functions

func Bytes2String added in v1.0.35

func Bytes2String(b []byte) string

Byte2String []byte -> string

func Get added in v1.0.32

func Get() *byteBuffer

Get returns an empty byte buffer from the pool.

Got byte buffer may be returned to the pool via Put call. This reduces the number of memory allocations required for byte buffer management.

func NewByteBuffer added in v1.0.35

func NewByteBuffer(b []byte, maxSize uint) *byteBuffer

func NewLoopQueue

func NewLoopQueue[T any](size int) *loopQueue[T]

func NewStack

func NewStack[T any](size int) *stack[T]

func Put added in v1.0.32

func Put(b *byteBuffer)

Put returns byte buffer to the pool.

byteBuffer.B mustn't be touched after returning it to the pool. Otherwise, data races will occur.

func String2Bytes added in v1.0.35

func String2Bytes(s string) []byte

String2Bytes string -> []byte

Types

type CacheUnit

type CacheUnit[T any] struct {
	// contains filtered or unexported fields
}

type Pool added in v1.0.32

type Pool struct {
	DefaultSize uint64

	BufferMaxSize uint
	// contains filtered or unexported fields
}

Pool represents byte buffer pool.

Distinct pools may be used for distinct types of byte buffers. Properly determined byte buffer types with their own pools may help reducing memory waste.

func (*Pool) Get added in v1.0.32

func (p *Pool) Get() *byteBuffer

Get returns new byte buffer with zero length.

The byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead.

func (*Pool) Put added in v1.0.32

func (p *Pool) Put(b *byteBuffer)

Put releases byte buffer obtained via Get to the pool.

The buffer mustn't be accessed after returning to the pool.

Jump to

Keyboard shortcuts

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