thread

package
v0.0.0-...-26f4575 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parallelism

func Parallelism() int

Parallelism returns the current parellism.

This defaults to the number of CPUs.

func Parallelize

func Parallelize(ctx context.Context, jobs []func(context.Context) error, options ...ParallelizeOption) error

Parallelize runs the jobs in parallel.

A max of Parallelism jobs will be run at once. Returns the combined error from the jobs.

func SetParallelism

func SetParallelism(parallelism int)

SetParallelism sets the parallelism.

If parallelism < 1, this sets the parallelism to 1.

Types

type ParallelizeOption

type ParallelizeOption func(*parallelizeOptions)

ParallelizeOption is an option to Parallelize.

func ParallelizeWithCancel

func ParallelizeWithCancel(cancel context.CancelFunc) ParallelizeOption

ParallelizeWithCancel returns a new ParallelizeOption that will call the given context.CancelFunc if any job fails.

func ParallelizeWithMultiplier

func ParallelizeWithMultiplier(multiplier int) ParallelizeOption

ParallelizeWithMultiplier returns a new ParallelizeOption that will use a multiple of Parallelism() for the number of jobs that can be run at once.

The default is to only do Parallelism() number of jobs. A multiplier of <1 has no meaning.

Jump to

Keyboard shortcuts

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