parallelizer

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package parallelizer features some utilities to help run tasks in parallel.

Index

Constants

View Source
const (
	// The default number of workers.
	DefaultNumOfWorkers = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorFlag

type ErrorFlag struct {
	// contains filtered or unexported fields
}

ErrorFlag is a flag for indicating whether an error has occurred when running tasks in parallel with the parallelizer.

func NewErrorFlag

func NewErrorFlag() *ErrorFlag

NewErrorFlag returns an error flag.

func (*ErrorFlag) Lower

func (f *ErrorFlag) Lower() error

Lower lowers the error flag and returns the error that was used to raise the flag; it returns nil if the flag has not been raised.

func (*ErrorFlag) Raise

func (f *ErrorFlag) Raise(err error)

Raise raises the error flag with an error; if the flag has been raised, it will return immediately.

type Parallerlizer

type Parallerlizer struct {
	// contains filtered or unexported fields
}

Parallelizer helps run tasks in parallel.

func NewParallelizer

func NewParallelizer(workers int) *Parallerlizer

NewParallelizer returns a Parallelizer for running tasks in parallel.

func (*Parallerlizer) ParallelizeUntil

func (p *Parallerlizer) ParallelizeUntil(ctx context.Context, pieces int, doWork workqueue.DoWorkPieceFunc, operation string)

ParallelizeUntil wraps workqueue.ParallelizeUntil for running tasks in parallel.

Jump to

Keyboard shortcuts

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