package
Version:
v0.0.1
Opens a new window with list of versions in this module.
Published: Feb 2, 2025
License: Apache-2.0
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
¶
Package pool provides internal pool utilities.
type Pool[T any] struct {
}
Pool 针对 sync.Pool 的封装,提供强类型对象池
func New[T any](fn func() T) *Pool[T]
New 返回一个新的存储 T 的 Pool,如果 Pool 中不存在 T,使用 NewFn 函数创建
func (p *Pool[T]) Get() T
Get 从 Pool 中获取一个 T如果池为空,则创建一个新的 T
func (p *Pool[T]) Put(x T)
Put 将 T 重新放入池中
Source Files
¶
Click to show internal directories.
Click to hide internal directories.