Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
adding in concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
xmattstrongx committed Oct 8, 2017
1 parent 714239e commit 80d4e7a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/dep/root_analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) {
packages := make(map[string]bool)
dependencies := make(map[gps.ProjectRoot][]string)
logger := a.ctx.Err
concurrency := 4
sem := make(chan bool, concurrency)

syncDep := func(pr gps.ProjectRoot, sm gps.SourceManager) {
if err := sm.SyncSourceFor(gps.ProjectIdentifier{ProjectRoot: pr}); err != nil {
Expand Down Expand Up @@ -90,9 +92,16 @@ func (a *rootAnalyzer) cacheDeps(pr gps.ProjectRoot) {
continue
}

go syncDep(pr, a.sm)
sem <- true
go func() {
defer func() { <-sem }()
go syncDep(pr, a.sm)
}()
dependencies[pr] = []string{ip}
}
for i := 0; i < cap(sem); i++ {
sem <- true
}
}

func hasImportPathPrefix(s, prefix string) bool {
Expand Down

0 comments on commit 80d4e7a

Please sign in to comment.