github.com/sagernet/sing@v0.4.0-beta.19.0.20240518125136-f67a0988a636/common/task/task_deprecated.go (about) 1 package task 2 3 import "context" 4 5 func Run(ctx context.Context, tasks ...func() error) error { 6 var group Group 7 for _, task := range tasks { 8 currentTask := task 9 group.Append0(func(ctx context.Context) error { 10 return currentTask() 11 }) 12 } 13 return group.Run(ctx) 14 } 15 16 func Any(ctx context.Context, tasks ...func(ctx context.Context) error) error { 17 var group Group 18 for _, task := range tasks { 19 currentTask := task 20 group.Append0(func(ctx context.Context) error { 21 return currentTask(ctx) 22 }) 23 } 24 group.FastFail() 25 return group.Run(ctx) 26 }