Await completion of pull round before starting next (ref #2)

This commit is contained in:
Jakob Borg 2014-01-01 08:02:12 -05:00
parent 7e0be89052
commit 5b84b72d15

View File

@ -144,12 +144,15 @@ func (m *Model) puller() {
} }
var limiter = make(chan bool, opts.Advanced.FilesInFlight) var limiter = make(chan bool, opts.Advanced.FilesInFlight)
var allDone sync.WaitGroup
for _, n := range ns { for _, n := range ns {
limiter <- true limiter <- true
allDone.Add(1)
go func(n string) { go func(n string) {
defer func() { defer func() {
allDone.Done()
<-limiter <-limiter
}() }()
@ -178,6 +181,8 @@ func (m *Model) puller() {
} }
}(n) }(n)
} }
allDone.Wait()
} }
} }