workerpool

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	Execute()
	// Description is used to provide a summary of this job (used mainly for logging purposes)
	Description() string
}

Job represents a task that can be executed by a goroutine pool. Errors in execution should be logged but not returned, there is no retry mechanism in place.

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool represents a thread pool that distributes jobs

func CreateThreadPool

func CreateThreadPool(workerCount int, jobBufferLength int) Pool

CreateThreadPool instantiates a thread pool with the given number of workers and a job buffer with the given length

func (*Pool) Enqueue

func (p *Pool) Enqueue(job Job, staleAfter time.Duration)

Enqueue puts this job into the thread pool's queue, so that it will be run eventually

Jump to

Keyboard shortcuts

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