Skip to content

Limit the maximum number of goroutines running at the same time

License

Notifications You must be signed in to change notification settings

leyafo/concurrentrol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

concurrentrol

Limit the maximum number of goroutines running at the same time.

Usage

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

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

李亚夫 - leyafo

About

Limit the maximum number of goroutines running at the same time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages