tickgroup

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: BSD-3-Clause 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
}

A Group is a collection of goroutines working on subtask that are spawned on a set interval per task.

func New

func New(ctx context.Context) *Group

New returns a new Group that stops spawning subtasks when ctx is done.

func WithContext

func WithContext(ctx context.Context) (*Group, context.Context)

WithContext creates a child context from the given context, and uses that to control context cancelation.

func (*Group) Go

func (g *Group) Go(d time.Duration, f func() error)

Go spawns a subtask f every d. The goroutine terminates when an error is encountered. The first call to return a non-nil error cancels the group; its error will be returned by Wait.

func (*Group) Wait

func (g *Group) Wait() error

Wait blocks until all function calls from the Go method have returned, then returns the first non-nil error (if any) from them.

Jump to

Keyboard shortcuts

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