finishvoid.go 580 B

1234567891011121314151617181920212223242526272829303132333435
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/tal-tech/go-zero/core/mr"
  6. "github.com/tal-tech/go-zero/core/timex"
  7. )
  8. func main() {
  9. start := timex.Now()
  10. mr.FinishVoid(func() {
  11. time.Sleep(time.Second)
  12. }, func() {
  13. time.Sleep(time.Second * 5)
  14. }, func() {
  15. time.Sleep(time.Second * 10)
  16. }, func() {
  17. time.Sleep(time.Second * 6)
  18. }, func() {
  19. if err := mr.Finish(func() error {
  20. time.Sleep(time.Second)
  21. return nil
  22. }, func() error {
  23. time.Sleep(time.Second * 10)
  24. return nil
  25. }); err != nil {
  26. fmt.Println(err)
  27. }
  28. })
  29. fmt.Println(timex.Since(start))
  30. }