goworkers is a simple but effecient dynamic workers pool
type Pool
type Pool struct { ... }
Pool is a workers pool
ch := make(chan int)
pool := Init(func() {
i := <-ch
fmt.Println(i * i)
})
pool.Add(1)
ch <- 2
ch <- 3
wait := pool.Stop()
ch <- 4
<-wait
Output:
4
9
16