pools

package
v0.0.0-...-32fb1ab Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Acquire

func Acquire[T any](p *Pools) (T, bool)

Acquire returns a value from a generic pool.

func Release

func Release[T any](p *Pools, v T)

Release returns a value to a generic pool.

Types

type Pool

type Pool[T any] interface {
	// Get returns a value from the pool, or false.
	Get() (T, bool)

	// New returns a value from the pool, or creates a new one, panics if no new function.
	New() T

	// Put returns a value to the pool.
	Put(T)
}

Pool is a generic pool interface, which wraps sync.Pool.

func Acquire1

func Acquire1[T any](p *Pools) (T, bool, Pool[T])

Acquire1 returns a value from a generic pool, and its pool.

func GetPool

func GetPool[T any](p *Pools) Pool[T]

GetPool returns a pool for a type.

func NewPool

func NewPool[T any]() Pool[T]

NewPool returns a new pool without a new function.

func NewPoolFunc

func NewPoolFunc[T any](new func() T) Pool[T]

NewPoolFunc returns a new pool with a new function.

type Pools

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

Pools is a map of pools by type, experimental.

func NewPools

func NewPools() *Pools

NewPools returns a new pools instance.

Jump to

Keyboard shortcuts

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