Guest User

Untitled

a guest
Jul 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // workerPool creates or spawns new "work" goRoutines to process the "Jobs" channel
  2. func (m *Pool) workerPool(processor ProcessorFunc) {
  3. defer close(m.results)
  4. log.DEBUG.Printf("Worker Pool spawning new goRoutines, total: [%d]", m.numRoutines)
  5. var wg sync.WaitGroup
  6. for i := 0; i < m.numRoutines; i++ {
  7. wg.Add(1)
  8. go m.work(&wg, processor)
  9. log.DEBUG.Printf("Spawned work goRoutine [%d]", i)
  10. }
  11. log.DEBUG.Print("Worker Pool done spawning work goRoutines")
  12. wg.Wait()
  13. log.DEBUG.Print("all work goroutines done processing")
  14.  
  15. }
Add Comment
Please, Sign In to add comment