Skip to content

Instantly share code, notes, and snippets.

@dmora
Created July 19, 2018 22:41
Show Gist options
  • Save dmora/29bd2aaa1b5ce07f7fb0e4def666b786 to your computer and use it in GitHub Desktop.
Save dmora/29bd2aaa1b5ce07f7fb0e4def666b786 to your computer and use it in GitHub Desktop.
// Collect post processes the channel "Results" and calls the ResultProcessorFunc passed in as reference
// for further processing.
func (m *Pool) collect(proc ResultProcessorFunc) {
log.DEBUG.Print("goRoutine collect starting")
for result := range m.results {
outcome := proc(result)
log.DEBUG.Printf("Job with id: [%d] completed, outcome: %s", result.Job.id, outcome)
}
log.DEBUG.Print("goRoutine collect done, setting channel done as completed")
m.done <- true
m.completed = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment