package
Version:
v0.0.9
Opens a new window with list of versions in this module.
Published: Mar 11, 2025
License: Apache-2.0
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
Documentation
¶
type Pool[E any] struct {
}
Pool 是一个泛型化的 sync.Pool 封装,用于缓存和复用对象。
对象在释放回池时会被重置为零值。
func (p *Pool[E]) Acquire() *E
Acquire 从池中获取一个对象。如果池为空则创建新对象。
返回的对象会被重置为零值(通过 Release 时的重置保证)。
func (p *Pool[E]) Release(obj *E)
Release 将对象放回池中。如果对象为 nil 则直接返回。
放回前会将对象重置为零值以保证下次获取时的状态。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.