added waitgroup

This commit is contained in:
2022-08-13 21:55:17 +02:00
parent 87cf1e5631
commit 8ff928d7fa

View File

@@ -327,12 +327,14 @@ func (b *BuildManager) refreshSRCINFOs(ctx context.Context, path string) error {
step := int(float32(len(pkgBuilds)) / float32(runtime.NumCPU()))
cur := 0
wg := sync.WaitGroup{}
for i := 0; i < runtime.NumCPU(); i++ {
if cur+step > len(pkgBuilds) {
step -= cur + step - len(pkgBuilds)
}
wg.Add(1)
go func(pkgBuilds []string) {
defer wg.Done()
for _, pkgbuild := range pkgBuilds {
mPkgbuild := PKGBUILD(pkgbuild)
if mPkgbuild.FullRepo() == "trunk" || !Contains(conf.Repos, mPkgbuild.Repo()) || containsSubStr(mPkgbuild.FullRepo(), conf.Blacklist.Repo) {
@@ -390,6 +392,8 @@ func (b *BuildManager) refreshSRCINFOs(ctx context.Context, path string) error {
cur += step
}
wg.Wait()
return nil
}