To install the package, run:
go get github.com/go-zoox/concurrency
func TestConcurrency(t *testing.T) {
c := New(2)
for i := 0; i < 4; i++ {
fmt.Println("Adding task", i)
c.Add(func(args ...interface{}) {
index := args[0].(int)
fmt.Println("task", index, time.Now())
time.Sleep(3 * time.Second)
if index == 0 {
panic("panic error for task 0")
}
}, i)
}
c.Wait()
}
- eddycjy/gsema - a simple goroutine limit pool.
- go-zoox/waitgroup - Parallel-Controlled WaitGroup
- go-zoox/jobqueue - Powerful unlimited job queue with goroutine pool
- go-zoox/promise - JavaScript Promise Like with Goroutines
GoZoox is released under the MIT License.