taskgroup

package
v0.2.4-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTerminated = errors.New("taskgroup: terminated")

ErrTerminated returned if Group was already terminated.

Functions

This section is empty.

Types

type Group

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

Group manages set of tasks. Unlike errgroup.Group it is safe to call Go after Wait. If Group didn't terminate yet the behavior will be the same as for errgroup.Group, if it did Go will exit immediately.

Zero value is not a valid Group. Must be initialized using New.

func New

func New(opts ...Option) *Group

New returns instance of the Group.

func (*Group) Go

func (g *Group) Go(f func(ctx context.Context) error) error

Go spawns new goroutine that will run f, unless Group was already terminated. In the latter case ErrTerminated error will be returned.

func (*Group) Wait

func (g *Group) Wait() error

Wait until Group is terminated. First error is returned.

type Option

type Option func(g *Group)

Option to modify Group.

func WithContext

func WithContext(ctx context.Context) Option

WithContext passes parent context to use for the Group.

Jump to

Keyboard shortcuts

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