waitpool

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: MPL-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package waitpool provides a bounded sync.Pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WaitPool

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

WaitPool is a bounded sync.Pool. It is safe for concurrent use.

func New

func New[T any](max uint32, new func() T) *WaitPool[T]

New creates a new WaitPool with a maximum size of max. If max is 0, the pool is unbounded.

func (*WaitPool[T]) Count added in v0.6.2

func (p *WaitPool[T]) Count() int

Count returns the number of items in use.

func (*WaitPool[T]) Get

func (p *WaitPool[T]) Get() T

Get returns an item from the pool. If the pool is bounded and all items are in use, Get will block until an item is available.

func (*WaitPool[T]) Put

func (p *WaitPool[T]) Put(x T)

Put adds x to the pool.

Jump to

Keyboard shortcuts

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