update meter options

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-09-04 22:41:05 +03:00
parent 6c68d39081
commit 1a9236caad
2 changed files with 19 additions and 1 deletions

View File

@@ -1,6 +1,9 @@
package pool
import "sync"
import (
"bytes"
"sync"
)
type Pool[T any] struct {
p *sync.Pool
@@ -23,3 +26,11 @@ func (p Pool[T]) Get() T {
func (p Pool[T]) Put(t T) {
p.p.Put(t)
}
func NewBytePool(size int) Pool[T] {
return NewPool(func() []byte { return make([]byte, size) })
}
func NewBytesPool() Pool[T] {
return NewPool(func() *bytes.Buffer { return bytes.NewBuffer(nil) })
}