Skip to content

QuakePhil/generic-worker-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generic worker pool Go Reference

Go (1.18+) framework to run a pool of N workers

go get github.com/quakephil/generic-worker-pool@v0.2.2

Pool

workers := pool.New[I, O](input, worker, output)
result := workers.Wait(concurrency)

Input

func input(in chan<- I) {
  for ... {
    in <- I{ ... }
  }  
}

Worker

func worker(i I) I {
  i.update = ...
  return i
}

Output

func output(results <-chan I) (out O) {
  for result := range results {
    out.update += ...
  }
  return
}

Examples: https://github.com/QuakePhil/generic-worker-pool-examples