ctxgroup

package
v0.0.0-...-a4a3d96 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

A Group is a collection of goroutines working on subtasks that are part of the same overall task.

func New

func New(ctx context.Context) *Group

New returns a new Group and an associated context derived from ctx. Obtain the derived context from calling Group.Context().

The derived context is canceled the first time a function passed to Go returns a non-nil error or the first time Wait returns, whichever occurs first.

func (*Group) Context

func (g *Group) Context() context.Context

Context returns the context for this group. It may be canceled by the first function to return a non-nil error.

func (*Group) Go

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

Go calls the given function in a new goroutine. The first call to return a non-nil error cancels the group; its error will be returned by Wait.

func (*Group) Wait

func (g *Group) Wait() error

Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them.

Jump to

Keyboard shortcuts

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