Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // workerPool creates or spawns new "work" goRoutines to process the "Jobs" channel
- func (m *Pool) workerPool(processor ProcessorFunc) {
- defer close(m.results)
- log.DEBUG.Printf("Worker Pool spawning new goRoutines, total: [%d]", m.numRoutines)
- var wg sync.WaitGroup
- for i := 0; i < m.numRoutines; i++ {
- wg.Add(1)
- go m.work(&wg, processor)
- log.DEBUG.Printf("Spawned work goRoutine [%d]", i)
- }
- log.DEBUG.Print("Worker Pool done spawning work goRoutines")
- wg.Wait()
- log.DEBUG.Print("all work goroutines done processing")
- }
Add Comment
Please, Sign In to add comment