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

Function TestNegWorkers

workerpool_usage_test.go:14–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestNegWorkers(t *testing.T) {
15 pool := workerpool.New(-1, -1)
16
17 quit := make(chan struct{})
18
19 n := int64(runtime.NumCPU())
20 var backSlot int64
21 var job = func() {
22 atomic.AddInt64(&backSlot, 1)
23 <-quit
24 }
25 for pool.Queue(job, time.Millisecond*50) {
26 }
27
28 actual := atomic.LoadInt64(&backSlot)
29 assert.Equal(t, n, actual)
30
31 close(quit)
32
33 assert.NoError(t, waitFunc(pool.Stop, _timeout))
34}
35
36func TestZeroWorkers(t *testing.T) {
37 pool := workerpool.New(0, 0)

Callers

nothing calls this directly

Calls 2

waitFuncFunction · 0.85
QueueMethod · 0.80

Tested by

no test coverage detected