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.
A zero Group can be used if errors should not be tracked.
func WithNErrs ¶
WithNErrs returns a new Group with length of errs slice upto nerrs, upon Wait() errors are returned collected from all tasks.
func (*Group) Go ¶
Go calls the given function in a new goroutine.
The errors will be collected in errs slice and returned by Wait().
func (*Group) Wait ¶
Wait blocks until all function calls from the Go method have returned, then returns the slice of errors from all function calls.
func (*Group) WaitErr ¶
WaitErr blocks until all function calls from the Go method have returned, then returns the first error returned.
func (*Group) WithCancelOnError ¶
WithCancelOnError will return a context that is canceled as soon as an error occurs. The returned CancelFunc must always be called similar to context.WithCancel. If the supplied context is canceled any goroutines waiting for execution are also canceled.
func (*Group) WithConcurrency ¶
WithConcurrency allows to limit the concurrency of the group. This must be called before starting any async processes. There is no order to which functions are allowed to run. If n <= 0 no concurrency limits are enforced. g is modified and returned as well.