bytepool

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package bytepool defines pool for storing and reusing raw bytes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteBufferPool

type ByteBufferPool struct {
	sync.Pool
}

ByteBufferPool is a cached pool of reusable byte buffers.

func NewBufferPool

func NewBufferPool() *ByteBufferPool

NewBufferPool allocates a new ByteBufferPool.

func (*ByteBufferPool) Get

func (bbp *ByteBufferPool) Get() *bytes.Buffer

Get returns a bytes.Buffer from the pool.

func (*ByteBufferPool) Put

func (bbp *ByteBufferPool) Put(b *bytes.Buffer)

Put returns bytes.Buffer to the pool.

type BytePool

type BytePool struct {
	sync.Pool
}

BytePool is a cached pool of reusable byte slices.

func NewBytePool

func NewBytePool(length int) *BytePool

NewBytePool allocates a new BytePool with slices of equal length and capacity.

func (*BytePool) Get

func (bp *BytePool) Get() *[]byte

Get returns a byte slice from the pool.

func (*BytePool) Put

func (bp *BytePool) Put(b *[]byte)

Put returns a byte slice to the pool.

Jump to

Keyboard shortcuts

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