Remove redundant lock in listen

This commit is contained in:
Kiyon
2021-04-05 14:27:56 +08:00
committed by Christian Muehlhaeuser
parent 1ee40507ef
commit 2d602a1244

View File

@@ -65,7 +65,7 @@ func (r *standardRenderer) start() {
func (r *standardRenderer) stop() { func (r *standardRenderer) stop() {
r.flush() r.flush()
clearLine(r.out) clearLine(r.out)
r.done <- struct{}{} close(r.done)
} }
// listen waits for ticks on the ticker, or a signal to stop the renderer. // listen waits for ticks on the ticker, or a signal to stop the renderer.
@@ -77,11 +77,8 @@ func (r *standardRenderer) listen() {
r.flush() r.flush()
} }
case <-r.done: case <-r.done:
r.mtx.Lock()
r.ticker.Stop() r.ticker.Stop()
r.ticker = nil r.ticker = nil
r.mtx.Unlock()
close(r.done)
return return
} }
} }