MCPcopy Create free account
hub / github.com/divan/gotrace / pool

Function pool

examples/workers1.go:23–37  ·  view source on GitHub ↗
(wg *sync.WaitGroup, workers, tasks int)

Source from the content-addressed store, hash-verified

21}
22
23func pool(wg *sync.WaitGroup, workers, tasks int) {
24 ch := make(chan int)
25
26 for i := 0; i < workers; i++ {
27 time.Sleep(1 * time.Millisecond)
28 go worker(ch, wg)
29 }
30
31 for i := 0; i < tasks; i++ {
32 time.Sleep(10 * time.Millisecond)
33 ch <- i
34 }
35
36 close(ch)
37}
38
39func main() {
40 trace.Start(os.Stderr)

Callers 1

mainFunction · 0.70

Calls 2

makeFunction · 0.85
workerFunction · 0.70

Tested by

no test coverage detected