bpool

package
v0.0.0-...-7aac2a2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytePoolCap

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

BytePoolCap implements a leaky pool of []byte in the form of a bounded channel.

func NewBytePoolCap

func NewBytePoolCap(maxSize uint64, width int, capwidth int) (bp *BytePoolCap)

NewBytePoolCap creates a new BytePool bounded to the given maxSize, with new byte arrays sized based on width.

func (*BytePoolCap) CurrentSize

func (bp *BytePoolCap) CurrentSize() int

CurrentSize returns current size of buffer pool

func (*BytePoolCap) Get

func (bp *BytePoolCap) Get() (b []byte)

Get gets a []byte from the BytePool, or creates a new one if none are available in the pool.

func (*BytePoolCap) Populate

func (bp *BytePoolCap) Populate()

Populate - populates and pre-warms the byte pool, this function is non-blocking.

func (*BytePoolCap) Put

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

Put returns the given Buffer to the BytePool.

func (*BytePoolCap) Width

func (bp *BytePoolCap) Width() (n int)

Width returns the width of the byte arrays in this pool.

func (*BytePoolCap) WidthCap

func (bp *BytePoolCap) WidthCap() (n int)

WidthCap returns the cap width of the byte arrays in this pool.

type Pool

type Pool[T any] struct {
	New func() T
	// contains filtered or unexported fields
}

Pool is a single type sync.Pool with a few extra properties: If New is not set Get may return the zero value of T.

func (*Pool[T]) Get

func (p *Pool[T]) Get() T

Get will retuen a new T

func (*Pool[T]) Put

func (p *Pool[T]) Put(t T)

Put a used T.

Jump to

Keyboard shortcuts

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