pool

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pool provides a pool for reusing objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllRefsCount

func AllRefsCount() map[string]int

AllRefsCount returns the reference count of all pools.

Types

type Synced

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

Synced is a pool that is safe for concurrent use.

func Register

func Register[T any](name string) *Synced[T]

Register registers a new pool with the given name.

func (*Synced[T]) Get

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

Get returns an object from the pool. If the pool is empty, nil is returned.

func (*Synced[T]) Put

func (p *Synced[T]) Put(v T)

Put puts an object back to the pool.

func (*Synced[T]) RefsCount

func (p *Synced[T]) RefsCount() int

RefsCount returns the reference count of the pool.

type Trackable

type Trackable interface {
	// RefsCount returns the reference count of the pool.
	RefsCount() int
}

Trackable is the interface that wraps the RefsCount method.

Jump to

Keyboard shortcuts

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