Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPoolClosed = errors.New("pool is closed") ErrPoolFull = errors.New("pool is full") )
Functions ¶
This section is empty.
Types ¶
type CappedPool ¶ added in v1.3.0
type CappedPool[V any] struct { New func() V Closer func(V) // contains filtered or unexported fields }
CappedPool is a pool that will pool a limited number of values
func InitCappedPool ¶ added in v1.3.0
func InitCappedPool[V any](p *CappedPool[V], cap int) *CappedPool[V]
func NewCappedPool ¶ added in v1.3.0
func NewCappedPool[V any](cap int) *CappedPool[V]
func (*CappedPool[V]) Close ¶ added in v1.3.0
func (p *CappedPool[V]) Close()
func (*CappedPool[V]) Get ¶ added in v1.3.0
func (p *CappedPool[V]) Get(ctx context.Context) (v V, err error)
func (*CappedPool[V]) Put ¶ added in v1.3.0
func (p *CappedPool[V]) Put(v V) error
type ConcurrencyPool ¶ added in v1.3.0
type ConcurrencyPool[V any] struct { *CappedPool[V] // The minimum duration the Get can be blocked. The default is one second. BlockInterval time.Duration // contains filtered or unexported fields }
func InitConcurrencyPool ¶ added in v1.3.0
func InitConcurrencyPool[V any](p *CappedPool[V], cap int) *ConcurrencyPool[V]
func NewConcurrencyPool ¶ added in v1.3.0
func NewConcurrencyPool[V any](cap int) *ConcurrencyPool[V]
func (*ConcurrencyPool[V]) Get ¶ added in v1.3.0
func (p *ConcurrencyPool[V]) Get(ctx context.Context) (v V, err error)
func (*ConcurrencyPool[V]) Put ¶ added in v1.3.0
func (p *ConcurrencyPool[V]) Put(v V) error
func (*ConcurrencyPool[V]) Release ¶ added in v1.3.0
func (p *ConcurrencyPool[V]) Release(v V)
type NilPool ¶ added in v1.3.0
type NilPool[V any] struct { New func() V Closer func(V) }
type Pool ¶
type Pool[V any] interface { // Get returns a value qualifies specified filter from the pool. Get(context.Context) (V, error) // Put puts a function back to the pool. Put(V) error // Close closes the pool. Close() }
Pool defines a pool that supports eviction awareness and get value by specified filters.
Click to show internal directories.
Click to hide internal directories.