taskch

package module
v0.0.0-...-027d03a Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: MIT Imports: 1 Imported by: 2

README

taskch - Simple goroutine manager

GoDoc Build Status MIT License

This repository contains a Go package taskch which allows multiple goroutines to be joined.

import "github.com/snsinfu/go-taskch"

func doTasks() error {
	tasks := taskch.New()
	
	tasks.Go(func() error {
		return nil
	})
	
	tasks.Go(func() error {
		return nil
	})
	
	return tasks.Wait()
}

License

MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

type T struct {
	// contains filtered or unexported fields
}

T is the taskch type that manages collection of concurrent tasks. A task is a function, executed as a goroutine, returning an error to indicate success or failure.

func New

func New() *T

New creates a taskch object.

func (*T) Go

func (tch *T) Go(task func() error)

Go launches a task as a goroutine.

func (*T) Wait

func (tch *T) Wait() error

Wait blocks until all the tasks to success or any of the tasks to fail. In the latter case, one of the errors is returned. To ensure that all tasks to finish, repeatedly call Wait until nil is returned.

Jump to

Keyboard shortcuts

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