Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Line_end = "\n"
Functions ¶
func With_cancel ¶
func With_cancel(parent *Group) option
Use With_cancel() as the context to New(). Will panic if context is already set. Will panic if parent is nil. Register/Unregister use the parent's WaitGroup.
parent goroutine will not wait on the child. parent.Cancel() will call child.Cancel(). child.Cancel() will not call parent.Cancel().
func With_cancel_nowait ¶
Use With_cancel_nowait() as the context to New(). If ctx is a *gogroup.Group, the parent will not Wait().
parent goroutine will not wait on the child. parent.Cancel() will call child.Cancel(). child.Cancel() will not call parent.Cancel().
func With_timeout ¶
Will panic if gg is nil or context is already set.
parent.Cancel() will call child.Cancel(). child.Cancel() will not call parent.Cancel(). child timeout will not cancel parent. child timeout will not cancel parent.
func With_timeout_nowait ¶
Use With_timeout_nowait() as the context to New().
parent goroutine will not wait on the child. parent.Cancel() will call child.Cancel(). child.Cancel() will not call parent.Cancel(). child timeout will not cancel parent.
Types ¶
type Group ¶
type Group struct { context.Context context.CancelFunc Interrupted bool // 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(opt ...option) (r *Group)
New returns a Group using with zero or more options. If a context is not provided in an option, With_cancel() will be used. The Group.Context is canceled when either a Go() func returns or a func using Register()/Unregister(). New must be called to make a Group.
func (*Group) Register ¶
Register increments the internal sync.WaitGroup. Unregister() must be called with the returned int to end Group.Wait(). goroutines using Register/Unregister must end upon receipt from the Group.Ctx.Done() channel.
func (*Group) Unregister ¶
Unregister decrements the internal sync.WaitGroup and calls Group.Cancel(). It is safe to call Unregister multiple times.