goroutine

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachPanicHandle

func AttachPanicHandle(f func()) func()

func CheckGoroutineErr

func CheckGoroutineErr(errCtx context.Context) error

Types

type Job

type Job func()

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

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

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

Will release resources used by pool

func (*Pool) SendJob

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

func (*Pool) SendJobWithDeadline

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

func (*Pool) SendJobWithTimeout

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

func (*Pool) WaitAll

func (p *Pool) WaitAll()

Will wait for all jobs to finish.

func (*Pool) WaitCount

func (p *Pool) WaitCount(count int)

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