Skip to content

lestrrat-go/rungroup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rungroup

Control multiple goroutines from one object.

var g rungroup.Group

for i := 0; i < 10; i++ {
  i := i
  g.Add(rungroup.ActorFunc(func(ctx context.Context) error {
    if i%2 == 1 {
      return fmt.Errorf(`%d`, i)
    }
    return nil
  }))
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := g.Run(ctx)

time.Sleep(time.Second)
cancel()

if !assert.Len(t, err, 5) {
  return
}

About

Control execution of multiple goroutines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages