pool

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package pool provides internal pool utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool 针对 sync.Pool 的封装,提供强类型对象池

func New

func New[T any](fn func() T) *Pool[T]

New 返回一个新的存储 T 的 Pool,如果 Pool 中不存在 T,使用 NewFn 函数创建

func (*Pool[T]) Get

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

Get 从 Pool 中获取一个 T如果池为空,则创建一个新的 T

func (*Pool[T]) Put

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

Put 将 T 重新放入池中

Jump to

Keyboard shortcuts

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