concurrent

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 2 Imported by: 26

Documentation

Overview

Package concurrent provides a simple way to run functions concurrently and then reap the results.

Package concurrent allows cuncurrent running of provided functions, by default limiting the parallelism to the number of CPUs. The functions return an error value and these may be reaped at the end.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

State maintains state needed to manage running functions concurrently.

func NewState

func NewState(numConcurrent uint) *State

NewState returns a new State.

func NewStateWithLinearConcurrencyIncrease

func NewStateWithLinearConcurrencyIncrease(initialNumConcurrent uint,
	maximumNumConcurrent uint) *State

func (*State) GoRun

func (state *State) GoRun(doFunc func() error) error

GoRun will run the provided function in a goroutine. If the function returns a non-nil error, this will be returned in a future call to GoRun or by Reap. GoRun cannot be called concurrently with GoRun or Reap.

func (*State) Reap

func (state *State) Reap() error

Reap returns the first error encountered by the functions and waits for remaining functions to complete. The State can no longer be used after Reap.

Jump to

Keyboard shortcuts

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