template

package
v0.0.0-...-ad801e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketizedValuePool

type BucketizedValuePool struct {
	// contains filtered or unexported fields
}

BucketizedValuePool is a bucketized value pool.

func NewBucketizedValuePool

func NewBucketizedValuePool(sizes []ValueBucket, opts *ValuePoolOptions) *BucketizedValuePool

NewBucketizedValuePool creates a bucketized object pool.

func (*BucketizedValuePool) Get

func (p *BucketizedValuePool) Get(capacity int) GenericValue

Get gets a value from the pool.

func (*BucketizedValuePool) Init

func (p *BucketizedValuePool) Init(alloc func(capacity int) GenericValue)

Init initializes the bucketized pool.

func (*BucketizedValuePool) Put

func (p *BucketizedValuePool) Put(v GenericValue, capacity int)

Put puts a value to the pool.

type BucketizedValuePoolConfiguration

type BucketizedValuePoolConfiguration struct {
	// The pool bucket configuration.
	Buckets []ValuePoolBucketConfiguration `yaml:"buckets"`

	// The watermark configuration.
	Watermark ValuePoolWatermarkConfiguration `yaml:"watermark"`
}

BucketizedValuePoolConfiguration contains configuration for bucketized pools.

func (*BucketizedValuePoolConfiguration) NewBuckets

NewBuckets create a new list of buckets.

func (*BucketizedValuePoolConfiguration) NewPoolOptions

func (c *BucketizedValuePoolConfiguration) NewPoolOptions(
	instrumentOptions instrument.Options,
) *ValuePoolOptions

NewPoolOptions creates a new set of pool options.

type GenericBucketizedValueArrayPool

type GenericBucketizedValueArrayPool interface {
	generic.Type

	Get(capacity int) []GenericValue
	Put(values []GenericValue, capacity int)
}

GenericBucketizedValueArrayPool is a generic bucketized value array pool.

type GenericValue

type GenericValue generic.Type

GenericValue is a value type.

type RefCountedPooledValueArray

type RefCountedPooledValueArray struct {
	// contains filtered or unexported fields
}

RefCountedPooledValueArray is a refcounted, pooled generic value array.

func NewRefCountedPooledValueArray

func NewRefCountedPooledValueArray(
	vals []GenericValue,
	p GenericBucketizedValueArrayPool,
	resetFn func(values []GenericValue),
) *RefCountedPooledValueArray

NewRefCountedPooledValueArray creates a new refcounted, pooled generic value array.

func (*RefCountedPooledValueArray) Append

Append appends a value to the value array.

func (*RefCountedPooledValueArray) Close

func (rv *RefCountedPooledValueArray) Close()

Close closes the ref counted array.

func (*RefCountedPooledValueArray) Get

Get returns the underlying raw value array.

func (*RefCountedPooledValueArray) Snapshot

Snapshot takes a snapshot of the current values in the refcounted array. The returned snapshot shares the backing array with the source array but keeps a copy of the array slice as the snapshot. As a result, new values appended to the end of the array after the snapshot is taken is invisible to the snapshot.

type ValueBucket

type ValueBucket struct {
	// Capacity is the size of each element in the bucket.
	Capacity int

	// Count is the number of fixed elements in the bucket.
	Count int

	// Options is an optional override to specify options to use for a bucket,
	// specify nil to use the options specified to the bucketized pool
	// constructor for this bucket.
	Options *ValuePoolOptions
}

ValueBucket specifies a bucket.

type ValuePool

type ValuePool struct {
	// contains filtered or unexported fields
}

ValuePool is a value pool.

func NewValuePool

func NewValuePool(opts *ValuePoolOptions) *ValuePool

NewValuePool creates a new pool.

func (*ValuePool) Get

func (p *ValuePool) Get() GenericValue

Get gets a value from the pool.

func (*ValuePool) Init

func (p *ValuePool) Init(alloc func() GenericValue)

Init initializes the pool.

func (*ValuePool) Put

func (p *ValuePool) Put(v GenericValue)

Put returns a value to pool.

type ValuePoolBucketConfiguration

type ValuePoolBucketConfiguration struct {
	// The count of the items in the bucket.
	Count int `yaml:"count"`

	// The capacity of each item in the bucket.
	Capacity int `yaml:"capacity"`
}

ValuePoolBucketConfiguration contains configuration for a pool bucket.

func (*ValuePoolBucketConfiguration) NewBucket

NewBucket creates a new bucket.

type ValuePoolConfiguration

type ValuePoolConfiguration struct {
	// The size of the pool.
	Size *int `yaml:"size"`

	// The watermark configuration.
	Watermark ValuePoolWatermarkConfiguration `yaml:"watermark"`
}

ValuePoolConfiguration contains pool configuration.

func (*ValuePoolConfiguration) NewPoolOptions

func (c *ValuePoolConfiguration) NewPoolOptions(
	instrumentOpts instrument.Options,
) *ValuePoolOptions

NewPoolOptions creates a new set of pool options.

type ValuePoolOptions

type ValuePoolOptions struct {
	// contains filtered or unexported fields
}

ValuePoolOptions provide a set of options for the value pool.

func NewValuePoolOptions

func NewValuePoolOptions() *ValuePoolOptions

NewValuePoolOptions create a new set of value pool options.

func (*ValuePoolOptions) InstrumentOptions

func (o *ValuePoolOptions) InstrumentOptions() instrument.Options

InstrumentOptions returns the instrument options.

func (*ValuePoolOptions) RefillHighWatermark

func (o *ValuePoolOptions) RefillHighWatermark() float64

RefillHighWatermark returns the high watermark for stop refilling the pool.

func (*ValuePoolOptions) RefillLowWatermark

func (o *ValuePoolOptions) RefillLowWatermark() float64

RefillLowWatermark returns the low watermark for refilling the pool.

func (*ValuePoolOptions) SetInstrumentOptions

func (o *ValuePoolOptions) SetInstrumentOptions(v instrument.Options) *ValuePoolOptions

SetInstrumentOptions sets the instrument options.

func (*ValuePoolOptions) SetRefillHighWatermark

func (o *ValuePoolOptions) SetRefillHighWatermark(v float64) *ValuePoolOptions

SetRefillHighWatermark sets the high watermark for refilling the pool.

func (*ValuePoolOptions) SetRefillLowWatermark

func (o *ValuePoolOptions) SetRefillLowWatermark(v float64) *ValuePoolOptions

SetRefillLowWatermark sets the low watermark for refilling the pool.

func (*ValuePoolOptions) SetSize

func (o *ValuePoolOptions) SetSize(v int) *ValuePoolOptions

SetSize sets the pool size.

func (*ValuePoolOptions) Size

func (o *ValuePoolOptions) Size() int

Size returns pool size.

type ValuePoolWatermarkConfiguration

type ValuePoolWatermarkConfiguration struct {
	// The low watermark to start refilling the pool, if zero none.
	RefillLowWatermark float64 `yaml:"low" validate:"min=0.0,max=1.0"`

	// The high watermark to stop refilling the pool, if zero none.
	RefillHighWatermark float64 `yaml:"high" validate:"min=0.0,max=1.0"`
}

ValuePoolWatermarkConfiguration contains watermark configuration for pools.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL