Skip to content

Commit

Permalink
perf: RestrictParallel exec opti (#779)
Browse files Browse the repository at this point in the history
Co-authored-by: Jarvan <[email protected]>
  • Loading branch information
zhouxiaohuan and Jarvan authored Mar 14, 2023
1 parent 2b8ee1e commit dddbb72
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/util/xgo/goroutine.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ func RestrictParallel(restrict int, fns ...func()) func() {
var wg sync.WaitGroup
for _, fn := range fns {
wg.Add(1)
channel <- struct{}{}
go func(fn func()) {
defer wg.Done()
channel <- struct{}{}
defer func() {
wg.Done()
<-channel
}()
_ = try2(fn, nil)
<-channel
}(fn)
}
wg.Wait()
Expand Down

0 comments on commit dddbb72

Please sign in to comment.