You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
211 B

9 years ago
  1. package common
  2. import "sync"
  3. func Parallel(tasks ...func()) {
  4. var wg sync.WaitGroup
  5. wg.Add(len(tasks))
  6. for _, task := range tasks {
  7. go func(task func()) {
  8. task()
  9. wg.Done()
  10. }(task)
  11. }
  12. wg.Wait()
  13. }