Created
July 4, 2018 15:33
-
-
Save shawn111/c6b1cfb1f77f95fe7fd91a78f9dbced7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func KojiListLatestBuilds(repo string) []string { | |
wg := sync.WaitGroup{} | |
queue := make(chan string) | |
doWork := func(i int, pkg string) string { | |
build := KojiLatestBuild(repo, pkg) | |
fmt.Printf("Worker %d working on %s - %s\n", i, pkg, build) | |
return build | |
} | |
for worker := 0; worker < Limit; worker++ { | |
wg.Add(1) | |
go func(worker int) { | |
defer wg.Done() | |
for work := range queue { | |
doWork(worker, work) // blocking wait for work | |
} | |
}(worker) | |
} | |
pkgs := KojiListPackages(repo) | |
for _, pkg := range pkgs { | |
queue <- pkg | |
} | |
close(queue) | |
wg.Wait() | |
return []string{} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment