fix: lock renderer during stop/kill

This commit is contained in:
Christian Muehlhaeuser 2022-10-09 05:53:02 +02:00
parent e119cd88b2
commit b9bd01b79a
1 changed files with 8 additions and 0 deletions

View File

@ -76,7 +76,12 @@ func (r *standardRenderer) start() {
// stop permanently halts the renderer, rendering the final frame.
func (r *standardRenderer) stop() {
// flush locks the mutex
r.flush()
r.mtx.Lock()
defer r.mtx.Unlock()
r.out.ClearLine()
r.once.Do(func() {
close(r.done)
@ -91,6 +96,9 @@ func (r *standardRenderer) stop() {
// kill halts the renderer. The final frame will not be rendered.
func (r *standardRenderer) kill() {
r.mtx.Lock()
defer r.mtx.Unlock()
r.out.ClearLine()
r.once.Do(func() {
close(r.done)