pool

package
v2.0.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool is a generic wrapper around sync.Pool. If your T type implements Resetable, the resetter function will be called after the entry is returned to the pool.

func New

func New[T any](item func() T) Pool[T]

New creates a new Pool with the given function to create new entries.

func (*Pool[T]) Get

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

Get retrieves an entry from the pool.

func (*Pool[T]) Put

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

Put returns an entry to the pool, optionally resetting the entry if a resetter function is provided.

type Resetable

type Resetable interface {
	Reset()
}

Jump to

Keyboard shortcuts

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