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/[email protected]

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Languages