spool

package
v1.1.0-beta.0...-2a72e7f Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(opts *Options)

Option represents the optional function.

func WithBlocking

func WithBlocking(blocking bool) Option

WithBlocking indicates whether the pool is blocking.

type Options

type Options struct {
	Blocking bool
}

Options contains all options which will be applied when instantiating an pool.

func DefaultOption

func DefaultOption() *Options

DefaultOption is the default option.

type Pool

type Pool struct {
	pool.BasePool
	// contains filtered or unexported fields
}

Pool is a single goroutine pool. it can not reuse the goroutine.

func NewPool

func NewPool(name string, size int32, component util.Component, options ...Option) (*Pool, error)

NewPool create a single goroutine pool.

func (*Pool) Cap

func (p *Pool) Cap() int32

Cap returns the capacity of the pool.

func (*Pool) GetOriginConcurrency

func (p *Pool) GetOriginConcurrency() int32

GetOriginConcurrency return the concurrency of the pool at the init.

func (*Pool) ReleaseAndWait

func (p *Pool) ReleaseAndWait()

ReleaseAndWait releases the pool and waits for all tasks to be completed.

func (*Pool) Run

func (p *Pool) Run(fn func()) error

Run runs a function in the pool.

func (*Pool) RunWithConcurrency

func (p *Pool) RunWithConcurrency(fns chan func(), concurrency uint32) error

RunWithConcurrency runs a function in the pool with concurrency.

func (*Pool) Running

func (p *Pool) Running() int32

Running returns the number of running goroutines.

func (*Pool) Tune

func (p *Pool) Tune(size int32)

Tune changes the pool size.

Jump to

Keyboard shortcuts

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