fix: avoid Update deadlock by unlocking before display
This commit is contained in:
@@ -56,16 +56,16 @@ func newProgressIndicatorWithClock(total int, description string, c clock) *Prog
|
|||||||
|
|
||||||
func (p *ProgressIndicator) Update(current int) {
|
func (p *ProgressIndicator) Update(current int) {
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
defer p.mu.Unlock()
|
|
||||||
|
|
||||||
p.current = current
|
p.current = current
|
||||||
now := p.clock.Now()
|
now := p.clock.Now()
|
||||||
|
|
||||||
if now.Sub(p.lastUpdate) < 100*time.Millisecond {
|
if now.Sub(p.lastUpdate) < 100*time.Millisecond {
|
||||||
|
p.mu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
p.lastUpdate = now
|
p.lastUpdate = now
|
||||||
|
p.mu.Unlock()
|
||||||
p.display()
|
p.display()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user