pool

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 4 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 represents a generic pool of resources.

func New

func New[T any](factory func() (T, error), initialCapacity, maxSize int) (*Pool[T], error)

New creates a new Pool.

func (*Pool[T]) Close

func (s *Pool[T]) Close(releaseFunc func(T))

Close shuts down the pool and releases all resources.

func (*Pool[T]) Get

func (s *Pool[T]) Get() (ret T, err error)

Get retrieves a resource from the pool, creating a new one if necessary.

func (*Pool[T]) Put

func (s *Pool[T]) Put(tVal T) (err error)

Put returns a resource to the pool.

Jump to

Keyboard shortcuts

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