alitto / pond

🔘 Minimalistic and High-performance goroutine worker pool written in Go
MIT License
1.43k stars 60 forks source link

1 pool for 3 different tasks with the same number of workers on each task #51

Closed vodves-vodves closed 3 weeks ago

vodves-vodves commented 10 months ago

I'm a bit confused how I can make it so that I create 1 pool where I make submissions to 3 different tasks, but still have the same number of workers for each task

Example:

pool := pond.New(40, 0, pond.MinWorkers(40)) // 40 workers on each task

pool.Submit(func() {
      //task 1 with 40 workers
})

pool.Submit(func() {
      //task 2 with 40 workers
})

pool.Submit(func() {
      //task 3 with 40 workers
})

pool.StopAndWait()
asing1 commented 8 months ago

You should create a group of pool and then submit the task

Example:


pool := pond.New(40, 0, pond.MinWorkers(40)) // 40 workers on each task
pGroup := pool.Group()

pGroup.Submit(func() {
      //task 1 with 40 workers
})

pGroup.Submit(func() {
      //task 2 with 40 workers
})

pGroup.Submit(func() {
      //task 3 with 40 workers
})

pool.StopAndWait()