workerpool

package
v0.0.0-...-9cc56c7 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package workerpool provides an implementation of the worker pool pattern for a configurable number of arbitrary, generic jobs. For details on this pattern, refer to https://gobyexample.com/worker-pools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WorkerPool

type WorkerPool[J any, R any] struct {
	Size int
	// contains filtered or unexported fields
}

WorkerPool is a generic worker pool representation whose workers process inputs of type J and return outputs of type R.

func New

func New[J any, R any](size int, worker func(jobs <-chan J, results chan<- R)) *WorkerPool[J, R]

New returns a new WorkerPool for workers processing inputs of type J and returning outputs of type R.

func (*WorkerPool[J, R]) Run

func (wp *WorkerPool[J, R]) Run(jobs []J) (results []R)

Run processes jobs in workers processing inputs of type J and returning outputs of type R.

Jump to

Keyboard shortcuts

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