Never write go
statement again!
- Manual gorroutine handle:
h := tate.Go(func(){})
h.Join() // Ok
h.Join() // panic! -> Double join
- Fixed Scope:
tate.FixScope(func(s *Scope){
s.Go(func(){})
s.Go(func(){})
s.Go(func(){})
}) // Synchronous wait of all goroutines
- Dynamic Scope:
j := tate.DynScope(func(s *Scope){
s.Go(func(){})
s.Go(func(){})
s.Go(func(){})
})
j.Join() // Only at that point all goroutines are done
j.Join() // panic! -> Double join
- Repeater
rp := tate.NewRepeater()
// Repeats in infinite cycle each routine
rp.Go(func(){})
rp.Go(func(){})
// Instantly cancels all cycles and joins goroutines
rp.CancelJoin()
// We can do it again and again
rp.Go(func(){})
rp.Go(func(){})
rp.CancelJoin()
- Tree Design
- Inject Cancellation
- Maybe some functional style