Skip to content

go-zoox/concurrency

Repository files navigation

Concurrency - A Simple Goroutine Limit Pool

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/concurrency

Getting Started

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()
}

Inspired by

Related

License

GoZoox is released under the MIT License.

About

A Simple Goroutine Limit Pool

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages