Generic worker pool ![Go Reference](https://camo.githubusercontent.com/cc20b6ef2dac0f26775a027d59dd2be6a3d6dcd0150bdfe47bb778dd2ebe033a/68747470733a2f2f706b672e676f2e6465762f62616467652f6769746875622e636f6d2f7175616b657068696c2f67656e657269632d776f726b65722d706f6f6c2e737667)
Go (1.18+) framework to run a pool of N
workers
go get github.com/quakephil/generic-worker-pool@v0.2.2
workers := pool.New[I, O](input, worker, output)
- channel synchronization for
- concurrent runs of
Process()
- completion of
Output()
- concurrent runs of
result := workers.Wait(concurrency)
func input(in chan<- I) {
for ... {
in <- I{ ... }
}
}
func worker(i I) I {
i.update = ...
return i
}
func output(results <-chan I) (out O) {
for result := range results {
out.update += ...
}
return
}
Examples: https://github.com/QuakePhil/generic-worker-pool-examples