# README
concurrency
go concurrency library
Installation
go get -u github.com/iTrellis/concurrency
Usage
concurrency repo
// ConcurrencyRepo functions for go routings to run tasks
type ConcurrencyRepo interface {
// Invoke tasks: task must be functions
Invoke(tasks []interface{}) ([]Runner, error)
InvokeDuration(tasks []interface{}, timeout time.Duration) ([]Runner, error)
}
new and input a namespace's transaction
c := concurrency.New(100)
f := func(i int) (n int) {
fmt.Println(i, time.Now())
return i
}
var tasks []interface{}
for i := 0; i < 50; i++ {
tasks = append(tasks, f)
}
runners, err := c.Invoke(tasks)
for i := 0; i < 50; i++ {
fmt.Println(runners[i].Get.MapV(func(n int){fmt.Println("%3.d", n)}))
}
# Functions
New return a concurrency pool with number.
# Variables
concurrency errors.
concurrency errors.
concurrency errors.