genpool
Simple generic wrapper around sync.Pool.
Basic pool
var gPool = genpool.New[bytes.Buffer]()
Pool with function
var gPool = genpool.NewFunc[Ctx](func() *Ctx {
return &Ctx{
// ...
}
})
Using the pool
func something() {
buffer := gPool.Get()
defer gPool.Put(buffer)
// do something with buffer
}
License
This is free and unencumbered software released into the public domain.