pools

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenClose

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

OpenClose is a pool of resources which have an open and close cost to be amoritized by staying in the pool.

func NewOpenClose

func NewOpenClose[T any](n int, mk func(ctx context.Context) (T, error), close func(T) error) OpenClose[T]

func (*OpenClose[T]) Cap

func (p *OpenClose[T]) Cap() int

func (*OpenClose[T]) CloseAll

func (p *OpenClose[T]) CloseAll() (retErr error)

func (*OpenClose[T]) Give

func (p *OpenClose[T]) Give(ctx context.Context, x T) error

func (*OpenClose[T]) Len

func (p *OpenClose[T]) Len() int

func (*OpenClose[T]) Take

func (p *OpenClose[T]) Take(ctx context.Context) (T, error)

Jump to

Keyboard shortcuts

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