tpool

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package tpool provides a generic, type-safe sync.Pool wrapper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool[T any] sync.Pool

Pool is a type-safe wrapper around a sync.Pool. To obtain one, declare a variable or convert an existing sync.Pool to it. In the latter case, if the pool's New field is non-nil, it must return values which assert to T.

func (*Pool[T]) Get

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

Get pulls a value from the pool. It is a thin wrapper around *sync.Pool.Get and so mirrors its semantics. If the pool's New field is non-nil and returns a value which does not assert to T, then the result is the zero value of T.

func (*Pool[T]) Put

func (p *Pool[T]) Put(e T)

Put returns a value to the pool. It is a thin wrapper around *sync.Pool.Put and so mirrors its semantics.

Jump to

Keyboard shortcuts

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