async

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2018 License: MIT Imports: 0 Imported by: 1

README

async

Build Status Go Report Card GoDoc

A collection of methods for running functions concurrently.

Installation

go get -u github.com/eleniums/async

Example

Create some tasks to run:

foo := func() error {
    // do something
    return nil
}

bar := func() error {
    // do something else
    return nil
}

Run the tasks concurrently:

err := async.Run(foo, bar)
if err != nil {
    log.Fatalf("task returned an error: %v", err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(tasks ...Task) error

Run will execute the given tasks concurrently and stop if a task returns an error.

func RunForever

func RunForever(concurrent int, task Task) error

RunForever will execute the given task repeatedly on a set number of goroutines and stop if a task returns an error.

func RunLimited

func RunLimited(concurrent int, count int, task Task) error

RunLimited will execute the given task a set number of times on a set number of goroutines and stop if a task returns an error. Total times the task will be executed is equal to concurrent multiplied by count.

Types

type Task

type Task func() error

Task is a function that can be run concurrently.

Jump to

Keyboard shortcuts

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