|
3 years ago | |
---|---|---|
.appveyor.yml | 3 years ago | |
.gitlab-ci.yml | 3 years ago | |
LICENSE | 3 years ago | |
README.md | 3 years ago | |
doc.go | 3 years ago | |
go.mod | 3 years ago | |
pipeline.go | 3 years ago | |
pipeline_test.go | 3 years ago | |
revive.toml | 3 years ago | |
runner.go | 3 years ago | |
runner_test.go | 3 years ago | |
waitgroup.go | 3 years ago | |
waitgroup_test.go | 3 years ago |
Easy concurrent loops.
Package parallel provides a runner to run tasks with limited concurrency. Using this package, it should be straightforward to replace any loop with similar code that provides concurrency.
As with most projects for Go, installation is as easy as go get
.
Please refer to the documentation on godoc.org for API documentation.
An example of how the package can be used is below. The full source can be found on the Go playground.
urls := []string{
"http://www.golang.org/",
"http://www.google.com/",
"http://www.somestupidname.com/",
}
// Build a runner using the default context, and which will limit
// concurrency to the number of CPUs.
r := parallel.NewRunner(nil)
for _, url := range urls {
url := url
r.Go(func() {
// Fetch the URL.
http.Get(url)
})
}
// Wait for all HTTP fetches to complete.
r.Wait()
Development of this project is ongoing. If you find a bug or have any suggestions, please open an issue.
If you'd like to contribute, please fork the repository and make changes. Pull requests are welcome.
This project is licensed under the 3-Clause BSD License. See the LICENSE in the repository.