task

package
v2.0.212+incompatible Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: MIT Imports: 3 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
}

Group is a group of tasks which should each be executed concurrently, and which should be collectively blocked on until all are complete. Tasks should be preemptable, and the first task to return a non-nil error cancels the entire Group. While Group is used to invoke and wait on multiple goroutines, it is not itself thread-safe.

func NewGroup

func NewGroup(ctx context.Context) *Group

NewGroup returns a new, empty Group with the given Context.

func (*Group) Cancel

func (g *Group) Cancel()

Cancel the Group Context.

func (*Group) Context

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

Context returns the Group Context.

func (*Group) GoRun

func (g *Group) GoRun()

GoRun all queued functions. GoRun may be called only once: the second invocation will panic.

func (*Group) Queue

func (g *Group) Queue(desc string, fn func() error)

Queue a function for execution with the Group. Cannot be called after GoRun is invoked or Queue panics.

func (*Group) Wait

func (g *Group) Wait() error

Wait for started functions, returning only after all complete. The first encountered non-nil error is returned. GoRun must have been called or Wait panics.

Jump to

Keyboard shortcuts

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