gitalk icon indicating copy to clipboard operation
gitalk copied to clipboard

类型安全的Pool

Open utterances-bot opened this issue 1 year ago • 1 comments

类型安全的Pool

池(sync.Pool)是一组可单独保存(Set)和检索(Get)的临时对象集合。 存储在池中的任何项都可能在任何时候自动移除而无需通知。如果池在移除项时持有该对象的唯一引用,那么这个对象可能会被释放掉。 池能够确保在多个goroutine同时访问时的安全性。 池

https://colobu.com/2024/04/10/a-generic-sync-Pool/

utterances-bot avatar Apr 17 '24 07:04 utterances-bot

sync.Pool内部有锁,实用性不强,本来用这个 Pool 就是为了提高性能,结果频繁使用反而降低性能。

langhuihui avatar Apr 17 '24 07:04 langhuihui