coutil

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: BSD-3-Clause Imports: 1 Imported by: 2

README

About

Provides a work pool with a limited number of goroutines (threads) for processing an input slice of work items. It is useful where a large number of inputs should be processed in parallel but the outputs should be processed serially.

Example

See workpool_test.go for examples.

Licence

Please see the included BSD 3-clause LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WorkPool

func WorkPool[InputItem any, OutputItem any](workerCount int, inputItems []InputItem, operation func(InputItem) OutputItem, resultProcessor func(OutputItem))

WorkPool processes a slice of input items using a limited number of goroutines. The order in which output items are sent to the result processor is not guaranteed. [workerCount] is the number of goroutines that will work concurrently on the input items. [workItems] is a slice containing the input items that will be worked on. [operation] is a function that will execute within a goroutine and perform an operation on an input item and return an output item. [resultProcessor] is a function that executes on the calling thread and processes each output item generated by the work pool.

Types

This section is empty.

Jump to

Keyboard shortcuts

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