workgroup

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

workgroup provides a mechanism for controlling the lifetime of a group of related goroutines (workers). workgroup is distilled from similar ideas in Peter Bourgon's github.com/oklog/oklog/pkg/group and Dave Cheney's github.com/pkg/life.

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 manages a set of goroutines with related lifetimes.

func (*Group) Add

func (g *Group) Add(fn func(<-chan struct{}))

Add adds a function to the Group. The function will be exectuted in its own goroutine when Run is called. Add must be called before Run.

func (*Group) Run

func (g *Group) Run()

Run exectues each function registered with Add in its own goroutine. Run blocks until each function has returned. The first function to return will trigger the closure of the channel passed to each function, who should in turn, return.

Jump to

Keyboard shortcuts

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