open-vault/vendor/github.com/gammazero/workerpool
Jeff Mitchell 9ebc57581d
Switch to go modules (#6585)
* Switch to go modules

* Make fmt
2019-04-13 03:44:06 -04:00
..
.gitignore Switch to go modules (#6585) 2019-04-13 03:44:06 -04:00
.travis.yml Switch to go modules (#6585) 2019-04-13 03:44:06 -04:00
doc.go adding gcpkms secrets engine (#784) 2018-10-22 23:39:25 -07:00
go.test.sh Switch to go modules (#6585) 2019-04-13 03:44:06 -04:00
LICENSE adding gcpkms secrets engine (#784) 2018-10-22 23:39:25 -07:00
README.md adding gcpkms secrets engine (#784) 2018-10-22 23:39:25 -07:00
workerpool.go Update deps (#6580) 2019-04-12 11:51:37 -04:00

workerpool

Build Status Go Report Card codecov License

Concurrency limiting goroutine pool. Limits the concurrency of task execution, not the number of tasks queued. Never blocks submitting tasks, no matter how many tasks are queued.

GoDoc

This implementation builds on ideas from the following:

Installation

To install this package, you need to setup your Go workspace. The simplest way to install the library is to run:

$ go get github.com/gammazero/workerpool

Example

package main

import (
	"fmt"
	"github.com/gammazero/workerpool"
)

func main() {
	wp := workerpool.New(2)
	requests := []string{"alpha", "beta", "gamma", "delta", "epsilon"}

	for _, r := range requests {
		r := r
		wp.Submit(func() {
			fmt.Println("Handling request:", r)
		})
	}

	wp.StopWait()
}