Run NodesReferenceutils

pool

Package pool

import "github.com/luxfi/node/utils/pool"

Types

BufferPool

BufferPool is a pool for bytes.Buffer objects

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

ByteSlicePool

ByteSlicePool is a pool for byte slices of a specific size

func NewByteSlicePool(size int) *ByteSlicePool
func (p *ByteSlicePool) Get() []byte
func (p *ByteSlicePool) Put(b []byte)

MapPool

MapPool provides pooling for maps

func NewMapPool[K comparable, V any]() *MapPool[K, V]
func (p *MapPool[K, V]) Get() map[K]V
func (p *MapPool[K, V]) Put(m map[K]V)

ObjectPool

ObjectPool provides a generic object pool for reducing allocations

func NewObjectPool[T any](new func() T, reset func(T)) *ObjectPool[T]
func (p *ObjectPool[T]) Get() T
func (p *ObjectPool[T]) Put(obj T)

SlicePool

SlicePool provides pooling for slices

func NewSlicePool[T any](initialCap int) *SlicePool[T]
func (p *SlicePool[T]) Get() []T
func (p *SlicePool[T]) Put(s []T)