(wg *sync.WaitGroup)
| 147 | } |
| 148 | |
| 149 | func (w *worker) begin(wg *sync.WaitGroup) { |
| 150 | wg.Add(1) |
| 151 | go func() { |
| 152 | defer wg.Done() |
| 153 | var timeout <-chan time.Time |
| 154 | |
| 155 | for { |
| 156 | if w.shouldQuit(timeout) { |
| 157 | return |
| 158 | } |
| 159 | |
| 160 | if w.timeout > 0 { |
| 161 | timeout = time.After(w.timeout) |
| 162 | } |
| 163 | |
| 164 | if !w.registerInPool(timeout) { |
| 165 | return |
| 166 | } |
| 167 | |
| 168 | if !w.executeJob() { |
| 169 | return |
| 170 | } |
| 171 | } |
| 172 | }() |
| 173 | } |
| 174 | |
| 175 | func (w *worker) shouldQuit(timeout <-chan time.Time) (ok bool) { |
| 176 | select { |
no test coverage detected