MCPcopy Index your code
hub / github.com/sourcegraph/conc / ExampleResultPool

Function ExampleResultPool

pool/result_pool_test.go:14–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func ExampleResultPool() {
15 p := NewWithResults[int]()
16 for i := 0; i < 10; i++ {
17 i := i
18 p.Go(func() int {
19 return i * 2
20 })
21 }
22 res := p.Wait()
23 // Result order is nondeterministic, so sort them first
24 sort.Ints(res)
25 fmt.Println(res)
26
27 // Output:
28 // [0 2 4 6 8 10 12 14 16 18]
29}
30
31func TestResultGroup(t *testing.T) {
32 t.Parallel()

Callers

nothing calls this directly

Calls 2

GoMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…