MCPcopy Create free account
hub / github.com/dc0d/workerpool / executeJob

Method executeJob

workerpool.go:205–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

203}
204
205func (w *worker) executeJob() (ok bool) {
206 select {
207 case job, ok := <-w.todo:
208 if !ok {
209 return false
210 }
211
212 if job != nil {
213 job()
214 }
215 // we do not check for timeout or quit here because a registered worker
216 // is meant to do his job
217 // (& implementing unregistering would be complicated, inefficiet & unnecessary)
218 // unless the whole pool is quit (a prototype implemented using a priority queue
219 // - a heap - but it was just more complicated and did not add much; should
220 // investigate it more deeply; but this just works fine; after the burst,
221 // the expanded workers would just do their last job, eventually).
222 case <-w.poolQuit:
223 return false
224 }
225
226 return true
227}
228
229func (w *worker) initWorker(wg *sync.WaitGroup) {
230 if stopped(w.poolQuit) {

Callers 1

beginMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected