package pool
import "github.com/influxdata/influxdb/pkg/pool"
Package pool provides pool structures to help reduce garbage collector pressure.
Index ¶
- type Bytes
- type Generic
- func NewGeneric(max int, fn func(sz int) interface{}) *Generic
- func (p *Generic) Get(sz int) interface{}
- func (p *Generic) Put(c interface{})
- type LimitedBytes
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
Bytes is a pool of byte slices that can be re-used. Slices in this pool will not be garbage collected when not in use.
func NewBytes ¶
NewBytes returns a Bytes pool with capacity for max byte slices to be pool.
func (*Bytes) Get ¶
Get returns a byte slice size with at least sz capacity. Items returned may not be in the zero state and should be reset by the caller.
func (*Bytes) Put ¶
Put returns a slice back to the pool. If the pool is full, the byte slice is discarded.
type Generic ¶
type Generic struct {
// contains filtered or unexported fields
}
Generic is a pool of types that can be re-used. Items in this pool will not be garbage collected when not in use.
func NewGeneric ¶
NewGeneric returns a Generic pool with capacity for max items to be pool.
func (*Generic) Get ¶
Get returns a item from the pool or a new instance if the pool is empty. Items returned may not be in the zero state and should be reset by the caller.
func (*Generic) Put ¶
func (p *Generic) Put(c interface{})
Put returns an item back to the pool. If the pool is full, the item is discarded.
type LimitedBytes ¶
type LimitedBytes struct {
// contains filtered or unexported fields
}
LimitedBytes is a pool of byte slices that can be re-used. Slices in this pool will not be garbage collected when not in use. The pool will hold onto a fixed number of byte slices of a maximum size. If the pool is empty and max pool size has not been allocated yet, it will return a new byte slice. Byte slices added to the pool that are over the max size are dropped.
func NewLimitedBytes ¶
func NewLimitedBytes(capacity int, maxSize int) *LimitedBytes
NewBytes returns a Bytes pool with capacity for max byte slices to be pool.
func (*LimitedBytes) Get ¶
func (p *LimitedBytes) Get(sz int) []byte
Get returns a byte slice size with at least sz capacity. Items returned may not be in the zero state and should be reset by the caller.
func (*LimitedBytes) Put ¶
func (p *LimitedBytes) Put(c []byte)
Put returns a slice back to the pool. If the pool is full, the byte slice is discarded. If the byte slice is over the configured max size of any byte slice in the pool, it is discared.
Source Files ¶
- Version
- v1.12.0 (latest)
- Published
- Apr 8, 2025
- Platform
- linux/amd64
- Last checked
- 2 days ago –
Tools for package owners.