pool

package
v1.19.33-clash.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: GPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory[T any] func(context.Context) (T, error)

type Option

type Option[T any] func(*pool[T])

func WithAge

func WithAge[T any](maxAge int64) Option[T]

WithAge defined element max age (millisecond)

func WithEvict

func WithEvict[T any](cb func(T)) Option[T]

WithEvict set the evict callback

func WithSize

func WithSize[T any](maxSize int) Option[T]

WithSize defined max size of Pool

type Pool

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

Pool is for GC, see New for detail

func New

func New[T any](factory Factory[T], options ...Option[T]) *Pool[T]

func (Pool) Get

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

func (Pool) GetContext

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

func (Pool) Put

func (p Pool) Put(item T)

Jump to

Keyboard shortcuts

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