x

package
v0.0.0-...-5ee457c Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPoolCapacity = 2048

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool[T comparable] struct {
	// contains filtered or unexported fields
}

x.Pool is a specialized object pool implementation to replace sync.Pool. Unlike sync.Pool, x.Pool is backed by an MPMC queue, and objects in x.Pool will not be garbage collected for the lifetime of the pool, and its capacity is bounded. This is more useful if the objects in the pool should be long-lived.

func NewPool

func NewPool[T comparable](capacity int) *Pool[T]

func (*Pool[T]) Get

func (x *Pool[T]) Get() T

func (*Pool[T]) Put

func (x *Pool[T]) Put(item T)

func (*Pool[T]) WithFactory

func (x *Pool[T]) WithFactory(factory func() T) *Pool[T]

Jump to

Keyboard shortcuts

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