Skip to content

Commit

Permalink
fix: Read-lock tasks while drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-he committed Oct 25, 2022
1 parent 28fbb6d commit faf6555
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/model/backlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"io/ioutil"
"sort"
"sync"
"time"

"github.com/rs/zerolog/log"
Expand All @@ -17,6 +18,7 @@ import (
// to-do list.
type Backlog struct {
Tasks []Task
Mtx sync.RWMutex
}

// A Task remains to be done (or dropped) but is not yet scheduled.
Expand Down
3 changes: 3 additions & 0 deletions internal/ui/panes/tasks_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func (p *TasksPane) Draw() {

// draw tasks
func() {
p.backlog.Mtx.RLock()
defer p.backlog.Mtx.RUnlock()

yIter := y + 1
for _, task := range p.backlog.Tasks {
yIter += 1
Expand Down

0 comments on commit faf6555

Please sign in to comment.