Created
July 19, 2018 21:34
-
-
Save dmora/deb5cde2900ff72141a66087ac4dc15e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment