pool

package
v0.0.0-...-fd00b2c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 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 sync.Pool wrapped for type-safety

func NewPool

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

func (*Pool[T]) Get

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

func (*Pool[T]) Put

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

type ResetPool

type ResetPool[T Resetable] struct {
	*Pool[T]
}

ResetPool is a sync.Pool wrapped with a generic Resetable interface, the pool calls Reset before returning an item to the pool.

func NewResetPool

func NewResetPool[T Resetable](newFn func() T) *ResetPool[T]

func (*ResetPool[T]) Put

func (p *ResetPool[T]) Put(v T)

type Resetable

type Resetable interface {
	Reset()
}

Jump to

Keyboard shortcuts

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