Documentation ¶
Overview ¶
Package limitgroup provides synchronization, error propagation, and resource management for groups of goroutines working on common subtasks that are part of the same overall task.
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
}
Group works exactly like a golang.org/x/sync/errgroup.Group, but limits the maximum number of in-flight subtasks.
A zero Group is invalid. Use WithContext to construct a new Group.
func WithContext ¶
WithContext returns a new Group and an associated Context derived from ctx.
If the given limit is less than or equal to zero, a default of two times the number of CPUs is used.
func (*Group) Go ¶
Go calls the given function in a new goroutine after a semphore is acquired. If there is an error acquiring the semaphore, the error cancels the Group and is returned.
The first call to return a non-nil error cancels the group; its error will be returned by Wait.