goroutine

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGoroutineErr

func CheckGoroutineErr(errCtx context.Context) error

Types

type Job

type Job func()

Job Represents user request, function which should be executed in some worker.

type Pool

type Pool struct {
	JobQueue chan Job
	// contains filtered or unexported fields
}

func NewPool

func NewPool(numWorkers int, jobQueueLen int) *Pool

NewPool Will make pool of gorouting workers. numWorkers - how many workers will be created for this pool queueLen - how many jobs can we accept until we block

Returned object contains JobQueue reference, which you can use to send job to pool.

func (*Pool) JobDone

func (p *Pool) JobDone()

JobDone In case you are using WaitAll fn, you should call this method every time your job is done.

If you are not using WaitAll then we assume you have your own way of synchronizing.

func (*Pool) Release

func (p *Pool) Release()

Release Will release resources used by pool

func (*Pool) SendJob added in v1.2.8

func (p *Pool) SendJob(job func())

func (*Pool) SendJobWithDeadline added in v1.2.8

func (p *Pool) SendJobWithDeadline(job func(), t time.Time) bool

func (*Pool) SendJobWithTimeout added in v1.2.8

func (p *Pool) SendJobWithTimeout(job func(), t time.Duration) bool

func (*Pool) WaitAll

func (p *Pool) WaitAll()

WaitAll Will wait for all jobs to finish.

func (*Pool) WaitCount

func (p *Pool) WaitCount(count int)

WaitCount How many jobs we should wait when calling WaitAll. It is using WaitGroup Add/Done/Wait

Jump to

Keyboard shortcuts

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