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

Function waitFunc

workerpool_usage_test.go:196–216  ·  view source on GitHub ↗

nolint

(f func(), exitDelay time.Duration)

Source from the content-addressed store, hash-verified

194
195//nolint
196func waitFunc(f func(), exitDelay time.Duration) error {
197 funcDone := make(chan struct{})
198 go func() {
199 defer close(funcDone)
200 f()
201 }()
202
203 if exitDelay <= 0 {
204 <-funcDone
205
206 return nil
207 }
208
209 select {
210 case <-time.After(exitDelay):
211 return ErrTimeout
212 case <-funcDone:
213 }
214
215 return nil
216}
217
218var (
219 ErrTimeout = errors.New(`TIMEOUT`)

Callers 7

TestNegWorkersFunction · 0.85
TestZeroWorkersFunction · 0.85
TestAbsoluteTimeoutFunction · 0.85
TestTimeoutFunction · 0.85
TestQuitFunction · 0.85
TestWorkerPoolQuitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected