sync

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 5 Imported by: 2

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)
}

func (*NilPool[V]) Close added in v1.3.0

func (p *NilPool[V]) Close()

func (*NilPool[V]) Get added in v1.3.0

func (p *NilPool[V]) Get(_ context.Context) (v V, err error)

func (*NilPool[V]) Put added in v1.3.0

func (p *NilPool[V]) Put(v V) error

func (*NilPool[V]) Release added in v1.3.0

func (p *NilPool[V]) Release(v 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.

type WaitGroup

type WaitGroup struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func (*WaitGroup) Add

func (wg *WaitGroup) Add(delta int)

func (*WaitGroup) Done

func (wg *WaitGroup) Done()

func (*WaitGroup) IsWaiting

func (wg *WaitGroup) IsWaiting() bool

func (*WaitGroup) Reset added in v1.0.1

func (wg *WaitGroup) Reset()

type WaitPool added in v1.3.0

type WaitPool[V any] interface {
	Pool[V]

	// Release releases the quota occupied by a pooling value.
	Release(V)
}

WaitPool defines a pool that has limited capacity and will wait for a value to be returned if the pool is full.

Jump to

Keyboard shortcuts

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