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: 2 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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