1 Star 0 Fork 0

蒙蒙的男孩 / eosc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
pool.go 752 Bytes
一键复制 编辑 原始数据 按行查看 历史
蒙蒙的男孩 提交于 2024-01-10 11:57 . 0.15.2
/*
* Copyright (c) 2023. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
* Vestibulum commodo. Ut rhoncus gravida arcu.
*/
package pool
import "sync"
type Pool[T any] interface {
Get() T
PUT(t T)
}
type _Pool[T any] struct {
pool sync.Pool
}
func (p *_Pool[T]) Get() T {
v := p.pool.Get()
return v.(T)
}
func (p *_Pool[T]) PUT(t T) {
p.pool.Put(t)
}
func New[T any](new func() T) Pool[T] {
return &_Pool[T]{
pool: sync.Pool{New: func() any { return new() }},
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/meng_mengs_boys/eosc.git
git@gitee.com:meng_mengs_boys/eosc.git
meng_mengs_boys
eosc
eosc
v1.15.7

搜索帮助

344bd9b3 5694891 D2dac590 5694891