Limit the maximum number of goroutines running at the same time.
go get -u github.com/leyafo/concurrentrol
or you can copy the limit.go for anyway.
The simplest code.
import "github.com/leyafo/concurrentrol"
func foo(){
var count int32
concurrentrol.Run(10, 100, func(i int) error { //Running 100 tasks and concurrent task is 10.
atomic.AddInt32(&count, int32(i))
return nil
})
}
This project is licensed under the MIT License - see the LICENSE file for details.
李亚夫 - leyafo