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

Method begin

workerpool.go:149–173  ·  view source on GitHub ↗
(wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

147}
148
149func (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
175func (w *worker) shouldQuit(timeout <-chan time.Time) (ok bool) {
176 select {

Callers 1

initWorkerMethod · 0.95

Calls 3

shouldQuitMethod · 0.95
registerInPoolMethod · 0.95
executeJobMethod · 0.95

Tested by

no test coverage detected