go-pool:更好的通用池(sync.Pool)

时间:2021-05-26 22:25:23
【文件属性】:
文件名称:go-pool:更好的通用池(sync.Pool)
文件大小:123KB
文件格式:ZIP
更新时间:2021-05-26 22:25:23
go golang sync pool Go :star: 该项目向您表示感谢。 :up-right_arrow: 更好的同步池 此程序包是对sync程序包提供的Pool的精简包装。 Pool是必不可少的程序包,可通过减少内存分配数量来获得最佳性能。 额外功能 使池中的项目无效(因此它将不再被使用) 设置池的最大项目数 返回池中的项目数(空闲和使用中) 我什么时候应该使用游泳池? 如果您经常分配许多相同类型的对象,并且想要节省一些内存分配和垃圾分配开销,则@jrv 例子 import "github.com/rocketlaunchr/go-pool" pool := pool . New ( 5 ) // maximum of 5 items in pool pool . SetFactory ( func () interface {} { return & X {} }) item := pool . Borrow () defer item . Ret
【文件预览】:
go-pool-master
----go.mod(110B)
----assets()
--------logo.png(117KB)
----LICENSE(1KB)
----no_copy.go(90B)
----README.md(3KB)
----pool.go(5KB)
----item.go(646B)

网友评论