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