parallel

package
v0.0.0-...-631d120 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parallel

func Parallel[T any](fn func(g *errgroup.Group, returnc chan T) error) (output []T, _ error)

DO NOT USE TODO: errgroup instant fail? TODO: ordered results? WIP

Parallel wraps errgroup, and collects results to an UNORDERED slice. jc: I don't understand ctx enough to return the first error, dismiss results, and kill any running (sub)goroutines.

fn usually consists of a for loop of some kind (ex: bufio.Scanner). Inside the for loop, it shall call g.Go(<something>).

Don't forget to do i, xyz := xyz, hello before g.Go(func() error { return fooBar(i, xyz, returnc) }) (shadowing) https://golang.org/doc/faq#closures_and_goroutines

Types

This section is empty.

Jump to

Keyboard shortcuts

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