package
Version:
v0.1.9
Opens a new window with list of versions in this module.
Published: Mar 14, 2026
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
type Pool[T any] struct {
}
Pool is a generic wrapper around sync.Pool.
T is the type of object being pooled.
func NewPool[T any](factory func() T) *Pool[T]
NewPool creates a pool with a factory function that makes new T when empty.
func (p *Pool[T]) Get() T
Get retrieves an object from the pool.
If pool is empty, factory is called to create a new one.
func (p *Pool[T]) Put(v T)
Put returns an object back to the pool for reuse.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.