mirror of https://github.com/v2ray/v2ray-core
make sure err is propagated
parent
8d7fab6aea
commit
8ed119e3f6
|
@ -88,8 +88,8 @@ func OnFailure(task Task) ExecutionOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Single(task Task, opts ExecutionOption) Task {
|
func Single(task Task, opts ...ExecutionOption) Task {
|
||||||
return Run(append([]ExecutionOption{Sequential(task)}, opts)...)
|
return Run(append([]ExecutionOption{Sequential(task)}, opts...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run(opts ...ExecutionOption) Task {
|
func Run(opts ...ExecutionOption) Task {
|
||||||
|
@ -120,14 +120,17 @@ func executeParallel(ctx context.Context, tasks []Task) error {
|
||||||
|
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
<-s.Wait()
|
<-s.Wait()
|
||||||
go func(f func() error) {
|
go func(f Task) {
|
||||||
if err := f(); err != nil {
|
err := f()
|
||||||
select {
|
if err == nil {
|
||||||
case done <- err:
|
s.Signal()
|
||||||
default:
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case done <- err:
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
s.Signal()
|
|
||||||
}(task)
|
}(task)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue