From 8ff928d7fabeb34f2ce2c645b996b42e792c049f Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Sat, 13 Aug 2022 21:55:17 +0200 Subject: [PATCH] added waitgroup --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 295beb0..3e413fd 100644 --- a/main.go +++ b/main.go @@ -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 }