async

package module
v0.0.0-...-60d0beb Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: MIT Imports: 1 Imported by: 0

README

Go Async-Group

Go Async Group can be more easily manage goroutine.

CircleCI codecov Go Report Card GoDoc

errgroup has the goal is to cancel all asynchronous when at least one async fails.
This package is used to wait until all the executed asynchronous processing is finished.

Synopsis

func main() {
	var ag async.Group
	var sum, expected uint32
	for i := 0; i < times; i++ {
		expected++
		ag.Go(func() {
			atomic.AddUint32(&sum, 1)
		})
	}
	ag.Wait()
	fmt.Println(sum, expected)
}

If you want to use at your application, see example.

Installation

go get -u github.com/Code-Hex/go-async

Contribution

  1. Fork https://github.com/Code-Hex/go-async/fork
  2. Commit your changes
  3. Create a new Pull Request

I'm waiting for a lot of PR.

Author

codehex

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
}

A Group is a collection of goroutines working on async subtasks that are part of the same overall task.

func (*Group) Go

func (g *Group) Go(f func())

Go calls the given function in a new goroutine.

func (*Group) Wait

func (g *Group) Wait()

Wait blocks until all function calls working on background from the Go method have returned.

Jump to

Keyboard shortcuts

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