open-vault/vendor/github.com/gammazero/workerpool
Chris Hoffman dec2eb88b6 adding gcpkms secrets engine (#784) 2018-10-22 23:39:25 -07: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
doc.go adding gcpkms secrets engine (#784) 2018-10-22 23:39:25 -07:00
go.test.sh adding gcpkms secrets engine (#784) 2018-10-22 23:39:25 -07:00
workerpool.go adding gcpkms secrets engine (#784) 2018-10-22 23:39:25 -07:00

README.md

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