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

Function ExampleStream

stream/stream_test.go:12–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func ExampleStream() {
13 times := []int{20, 52, 16, 45, 4, 80}
14
15 stream := New()
16 for _, millis := range times {
17 dur := time.Duration(millis) * time.Millisecond
18 stream.Go(func() Callback {
19 time.Sleep(dur)
20 // This will print in the order the tasks were submitted
21 return func() { fmt.Println(dur) }
22 })
23 }
24 stream.Wait()
25
26 // Output:
27 // 20ms
28 // 52ms
29 // 16ms
30 // 45ms
31 // 4ms
32 // 80ms
33}
34
35func TestStream(t *testing.T) {
36 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.70
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…