start the pool only once

This commit is contained in:
Adrien Delorme 2018-09-12 17:04:10 -07:00
parent dfeca9f0df
commit be27775a3c
1 changed files with 5 additions and 1 deletions

View File

@ -44,9 +44,11 @@ func (spb *StackableProgressBar) New(identifier string) ProgressBar {
spb.wg.Add(1)
defer spb.mtx.Unlock()
start := false
if spb.pool == nil {
spb.pool = pb.NewPool()
go spb.cleanup()
start = true
}
bar := NewProgressBar(identifier)
@ -55,7 +57,9 @@ func (spb *StackableProgressBar) New(identifier string) ProgressBar {
spb.bars = append(spb.bars, bar)
spb.pool.Add(bar.ProgressBar)
spb.pool.Start()
if start {
spb.pool.Start()
}
return bar
}