parallel

package
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidParallelism = errors.New("degree of parallelism must be > 0")

Functions

func ForEach

func ForEach(total int, n int, process Processor) error

ForEach processes data in parallel. total is the total number of items to process. n is the degree of parallelism. process is called with the index of the item being processed.

ParallelFor acts as a semaphore over a total WaitGroup fan-out, and also coalesces errors into a single error result.

If callers need process to return actual data, they should allocate a slice of the data they need, and assign to the slice index while processing. See ParallelForFiles for an example usage.

Types

type Processor

type Processor func(idx int) error

Jump to

Keyboard shortcuts

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