wait

package
v0.0.0-...-60e5113 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2015 License: MIT, MIT Imports: 1 Imported by: 0

README

wait

GoDoc

wait is a Go package that provides Group, an extended version of sync.WaitGroup.

wait is similar to two other packages of which I'm aware:

  • tomb is a popular choice which is quite similar but has more features and a more complicated set of states (alive/dying/dead).
  • Camlistore has syncutil.Group which records multiple errors but does not support cancellation.

Documentation

Overview

Package wait provides Group, an extended version of sync.WaitGroup.

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 waits for a collection of goroutines to exit. With Wait, one may wait for all goroutines to exit and get the first error that was seen. Cooperative cancellation is also supported via Quit and the broadcast chan passed to each goroutine. The zero value of Group is ready to be used.

func (*Group) Go

func (g *Group) Go(f func(quit <-chan struct{}) error)

Go runs f in a new goroutine. The quit chan is closed to indicate that f should exit early, so f is expected to periodically receive from quit and immediately return nil if a value arrives. Quit is called automatically if f returns a non-nil error.

func (*Group) Quit

func (g *Group) Quit()

Quit asks all goroutines started with Go to exit (by closing the quit chan given to each function). After the first call to Quit, subsequent calls have no effect.

func (*Group) Wait

func (g *Group) Wait() error

Wait waits for all goroutines to exit and returns the first non-nil error seen.

Jump to

Keyboard shortcuts

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