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

Function worker

examples/workers1.go:11–21  ·  view source on GitHub ↗
(ch <-chan int, wg *sync.WaitGroup)

Source from the content-addressed store, hash-verified

9)
10
11func worker(ch <-chan int, wg *sync.WaitGroup) {
12 defer wg.Done()
13 for {
14 task, ok := <-ch
15 if !ok {
16 return
17 }
18 time.Sleep(1 * time.Millisecond)
19 fmt.Println("processing task", task)
20 }
21}
22
23func pool(wg *sync.WaitGroup, workers, tasks int) {
24 ch := make(chan int)

Callers 1

poolFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected