Skip to content

Commit

Permalink
fix: lock renderer during stop/kill
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Oct 9, 2022
1 parent e119cd8 commit b9bd01b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions standard_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit b9bd01b

Please sign in to comment.