package errgroup
Import Path
golang.org/x/sync/errgroup (on go.dev)
Dependency Relation
imports 3 packages, and imported by one package
Involved Source Files
Package errgroup provides synchronization, error propagation, and Context
cancelation for groups of goroutines working on subtasks of a common task.
go120.go
Package-Level Type Names (total 2, in which 1 is exported)
A Group is a collection of goroutines working on subtasks that are part of
the same overall task.
A zero Group is valid, has no limit on the number of active goroutines,
and does not cancel on error.
cancel func(error)
err error
errOnce sync.Once
sem chan token
wg sync.WaitGroup
Go calls the given function in a new goroutine.
It blocks until the new goroutine can be added without the number of
active goroutines in the group exceeding the configured limit.
The first call to return a non-nil error cancels the group's context, if the
group was created by calling WithContext. The error will be returned by Wait.
SetLimit limits the number of active goroutines in this group to at most n.
A negative value indicates no limit.
Any subsequent call to the Go method will block until it can add an active
goroutine without exceeding the configured limit.
The limit must not be modified while any goroutines in the group are active.
TryGo calls the given function in a new goroutine only if the number of
active goroutines in the group is currently below the configured limit.
The return value reports whether the goroutine was started.
Wait blocks until all function calls from the Go method have returned, then
returns the first non-nil error (if any) from them.
(*Group) done()
func WithContext(ctx context.Context) (*Group, context.Context)
Package-Level Functions (total 2, in which 1 is exported)
WithContext returns a new Group and an associated Context derived from ctx.
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.
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |