()
| 12 | ) |
| 13 | |
| 14 | func 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 | |
| 31 | func TestResultGroup(t *testing.T) { |
| 32 | t.Parallel() |