You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
crate/synchelper/bytes_buffer_pool.go

19 lines
422 B
Go

2 years ago
package synchelper
import "bytes"
// NewBytesBufferPool 返回新的 BytesBufferPool
func NewBytesBufferPool(initialSize, maximumSize int) BytesBufferPool {
return NewPool(
func() any {
return bytes.NewBuffer(make([]byte, 0, initialSize))
},
func(v *bytes.Buffer) bool {
return v.Cap() <= maximumSize
},
)
}
// BytesBufferPool 是 [*bytes.Buffer] 的资源池
type BytesBufferPool = Pool[*bytes.Buffer]