pool

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory = func(context.Context) (any, error)

type Option

type Option func(*pool)

func WithAge

func WithAge(maxAge int64) Option

WithAge defined element max age (millisecond)

func WithEvict

func WithEvict(cb func(any)) Option

WithEvict set the evict callback

func WithSize

func WithSize(maxSize int) Option

WithSize defined max size of Pool

type Pool

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

Pool is for GC, see New for detail

func New

func New(factory Factory, options ...Option) *Pool

func (Pool) Get

func (p Pool) Get() (any, error)

func (Pool) GetContext

func (p Pool) GetContext(ctx context.Context) (any, error)

func (Pool) Put

func (p Pool) Put(item any)

Jump to

Keyboard shortcuts

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