Documentation
¶
Overview ¶
Example (Parallel) ¶
conc.Run( func(onDispose dispose.It) error { fmt.Println("Hello #1.1") time.Sleep(10 * time.Millisecond) fmt.Println("Hello #1.2") time.Sleep(10 * time.Millisecond) onDispose(func() { fmt.Println("Dispose #1") }) return nil }, func(onDispose dispose.It) error { onDispose(func() { fmt.Println("Dispose #2") }) time.Sleep(5 * time.Millisecond) fmt.Println("Hello #2.1") time.Sleep(10 * time.Millisecond) fmt.Println("Hello #2.2") return nil }, )
Output: Hello #1.1 Hello #2.1 Hello #1.2 Hello #2.2 Dispose #2 Dispose #1
Example (Parallel_errors) ¶
err := conc.Run( func(onDispose dispose.It) error { fmt.Println("Hello #1.1") return errors.New("Error #1") }, func(onDispose dispose.It) error { time.Sleep(5 * time.Millisecond) fmt.Println("Hello #2.1") return errors.New("Error #2") }, ) fmt.Println(err)
Output: Hello #1.1 Hello #2.1 Error #1 Error #2
Example (Single) ¶
conc.Run(func(onDispose dispose.It) error { fmt.Println("Hello #1") onDispose(func() { fmt.Println("Dispose #1") }) return nil })
Output: Hello #1 Dispose #1
Example (Tree) ¶
err := conc.Run( func(onDispose dispose.It) error { fmt.Println("Hello #1.1") time.Sleep(10 * time.Millisecond) fmt.Println("Hello #1.2") time.Sleep(10 * time.Millisecond) onDispose(func() { fmt.Println("Dispose #1") }) return nil }, conc.Tasks( func(onDispose dispose.It) error { onDispose(func() { fmt.Println("Dispose #2") }) time.Sleep(5 * time.Millisecond) fmt.Println("Hello #2.1") time.Sleep(10 * time.Millisecond) fmt.Println("Hello #2.2") return nil }, func(onDispose dispose.It) error { time.Sleep(5 * time.Millisecond) onDispose(func() { fmt.Println("Dispose #3") }) time.Sleep(9 * time.Millisecond) fmt.Println("Hello #3.1") time.Sleep(10 * time.Millisecond) fmt.Println("Hello #3.2") return nil }, ), ) fmt.Println(err)
Output: Hello #1.1 Hello #2.1 Hello #1.2 Hello #3.1 Hello #2.2 Hello #3.2 Dispose #2 Dispose #3 Dispose #1 <nil>
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.