Skip to content

Instantly share code, notes, and snippets.

@dmora
Created July 19, 2018 20:53
Show Gist options
  • Save dmora/9ad12900b2d4f35d72b3bc80dfc66397 to your computer and use it in GitHub Desktop.
Save dmora/9ad12900b2d4f35d72b3bc80dfc66397 to your computer and use it in GitHub Desktop.
// Start starts the worker pool process
func (m *Pool) Start(resources []interface{}, procFunc ProcessorFunc, resFunc ResultProcessorFunc) {
log.DEBUG.Print("worker pool starting")
startTime := time.Now()
go m.allocate(resources)
m.done = make(chan bool)
go m.collect(resFunc)
go m.workerPool(procFunc)
<-m.done
endTime := time.Now()
diff := endTime.Sub(startTime)
log.DEBUG.Printf("total time taken: [%f] seconds", diff.Seconds())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment