| 203 | } |
| 204 | |
| 205 | func (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 | |
| 229 | func (w *worker) initWorker(wg *sync.WaitGroup) { |
| 230 | if stopped(w.poolQuit) { |