MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestNewTaskGroup

Function TestNewTaskGroup

internal/goman/task_group_test.go:11–30  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNewTaskGroup(t *testing.T) {
12 var group = goman.NewTaskGroup()
13 var m = map[int]bool{}
14
15 for i := 0; i < runtime.NumCPU()*2; i++ {
16 var index = i
17 group.Run(func() {
18 t.Log("task", index)
19
20 group.Lock()
21 _, ok := m[index]
22 if ok {
23 t.Error("duplicated:", index)
24 }
25 m[index] = true
26 group.Unlock()
27 })
28 }
29 group.Wait()
30}

Callers

nothing calls this directly

Calls 7

NewTaskGroupFunction · 0.92
LogMethod · 0.80
RunMethod · 0.45
LockMethod · 0.45
ErrorMethod · 0.45
UnlockMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected