pool

package
v1.22.32 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferPool

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

BufferPool is a pool for bytes.Buffer objects

func NewBufferPool

func NewBufferPool() *BufferPool

NewBufferPool creates a new buffer pool

func (*BufferPool) Get

func (p *BufferPool) Get() *bytes.Buffer

Get retrieves a buffer from the pool

func (*BufferPool) Put

func (p *BufferPool) Put(buf *bytes.Buffer)

Put returns a buffer to the pool

type ByteSlicePool

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

ByteSlicePool is a pool for byte slices of a specific size

func NewByteSlicePool

func NewByteSlicePool(size int) *ByteSlicePool

NewByteSlicePool creates a pool for byte slices

func (*ByteSlicePool) Get

func (p *ByteSlicePool) Get() []byte

Get retrieves a byte slice from the pool

func (*ByteSlicePool) Put

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

Put returns a byte slice to the pool

type MapPool

type MapPool[K comparable, V any] struct {
	// contains filtered or unexported fields
}

MapPool provides pooling for maps

func NewMapPool

func NewMapPool[K comparable, V any]() *MapPool[K, V]

NewMapPool creates a new map pool

func (*MapPool[K, V]) Get

func (p *MapPool[K, V]) Get() map[K]V

Get retrieves a map from the pool

func (*MapPool[K, V]) Put

func (p *MapPool[K, V]) Put(m map[K]V)

Put returns a map to the pool after clearing it

type ObjectPool

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

ObjectPool provides a generic object pool for reducing allocations

func NewObjectPool

func NewObjectPool[T any](new func() T, reset func(T)) *ObjectPool[T]

NewObjectPool creates a new object pool

func (*ObjectPool[T]) Get

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

Get retrieves an object from the pool

func (*ObjectPool[T]) Put

func (p *ObjectPool[T]) Put(obj T)

Put returns an object to the pool after resetting it

type SlicePool

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

SlicePool provides pooling for slices

func NewSlicePool

func NewSlicePool[T any](initialCap int) *SlicePool[T]

NewSlicePool creates a new slice pool

func (*SlicePool[T]) Get

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

Get retrieves a slice from the pool

func (*SlicePool[T]) Put

func (p *SlicePool[T]) Put(s []T)

Put returns a slice to the pool after clearing it

Jump to

Keyboard shortcuts

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