sizedpool

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 4 Imported by: 16 modules, 14 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 PoolOption

type PoolOption[T any] func(*SizedPool[T]) error

func WithPool

func WithPool[T any](p *sync.Pool) PoolOption[T]

func WithSize

func WithSize[T any](size int64) PoolOption[T]

type SizedPool

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

func New

func New[T any](options ...PoolOption[T]) (*SizedPool[T], error)

func (*SizedPool[T]) Get

func (sz *SizedPool[T]) Get(ctx context.Context) (T, error)

func (*SizedPool[T]) Put

func (sz *SizedPool[T]) Put(x T)

func (*SizedPool[T]) Size

func (sz *SizedPool[T]) Size() int64

Current size of the pool

func (*SizedPool[T]) Vary

func (sz *SizedPool[T]) Vary(ctx context.Context, x int64) error

Vary capacity by x - it's internally enqueued as a normal Acquire/Release operation as other Get/Put but tokens are held internally

Jump to

Keyboard shortcuts

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