grpool

package
v0.0.0-...-7aedd83 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	JobID   interface{}
	JobFunc func() (interface{}, error)
}

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

type Jobresult

type Jobresult struct {
	JobID    interface{}
	Timedout bool
	Result   interface{}
	Err      error
}

type Pool

type Pool struct {
	JobQueue chan Job

	Jobresult chan Jobresult
	// contains filtered or unexported fields
}

func NewPool

func NewPool(numWorkers int, jobQueueLen int, timeout time.Duration) *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) 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