Skip to content

Instantly share code, notes, and snippets.

@dmora
Created July 19, 2018 22:31
Show Gist options
  • Save dmora/0e4ccdef90c6f5931cfe6491898d705e to your computer and use it in GitHub Desktop.
Save dmora/0e4ccdef90c6f5931cfe6491898d705e to your computer and use it in GitHub Desktop.
// work performs the actual work by calling the processor and passing in the Job as reference obtained
// from iterating over the "Jobs" channel
func (m *Pool) work(wg *sync.WaitGroup, processor ProcessorFunc) {
defer wg.Done()
log.DEBUG.Print("goRoutine work starting")
for job := range m.jobs {
log.DEBUG.Printf("working on Job ID [%d]", job.id)
output := Result{job, processor(job.resource)}
m.results <- output
log.DEBUG.Printf("done with Job ID [%d]", job.id)
}
log.DEBUG.Print("goRoutine work done.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment