Skip to content

Commit

Permalink
add mutex around pocessFilterRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnveenman committed Feb 5, 2024
1 parent fd433db commit 9f5f5c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tui/proc-table.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,27 @@ func (pv *pcView) setTableSorter(sortBy ColumnID) {
}
}

func (pv *pcView) getProcessSearchRegex() *regexp.Regexp {
pv.processRegexMtx.Lock()
defer pv.processRegexMtx.Unlock()

return pv.processRegex
}

func (pv *pcView) resetProcessSearch() {
pv.processRegexMtx.Lock()
defer pv.processRegexMtx.Unlock()

pv.processRegex = nil
go pv.appView.QueueUpdateDraw(func() {
pv.fillTableData()
})
}

func (pv *pcView) searchProcess(search string, isRegex, caseSensitive bool) error {
pv.processRegexMtx.Lock()
defer pv.processRegexMtx.Unlock()

if search == "" {
pv.processRegex = nil
return nil
Expand Down
1 change: 1 addition & 0 deletions src/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type pcView struct {
sortMtx sync.Mutex
stateSorter StateSorter
processRegex *regexp.Regexp
processRegexMtx sync.Mutex
procColumns map[ColumnID]string
refreshRate time.Duration
cancelFn context.CancelFunc
Expand Down

0 comments on commit 9f5f5c1

Please sign in to comment.