-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdo_example_test.go
More file actions
35 lines (32 loc) · 669 Bytes
/
do_example_test.go
File metadata and controls
35 lines (32 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package flowmatic_test
import (
"fmt"
"time"
"github.com/carlmjohnson/flowmatic"
)
func ExampleDo() {
start := time.Now()
err := flowmatic.Do(
func() error {
time.Sleep(50 * time.Millisecond)
fmt.Println("hello")
return nil
}, func() error {
time.Sleep(100 * time.Millisecond)
fmt.Println("world")
return nil
}, func() error {
time.Sleep(200 * time.Millisecond)
fmt.Println("from flowmatic.Do")
return nil
})
if err != nil {
fmt.Println("error", err)
}
fmt.Println("executed concurrently?", time.Since(start) < 250*time.Millisecond)
// Output:
// hello
// world
// from flowmatic.Do
// executed concurrently? true
}