diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-26 23:48:11 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-28 11:59:45 +1100 |
commit | 39315ca1e2f526911ea35d9848b0427093e4080a (patch) | |
tree | f9c49bf7ab7915734b8b8f6413e4439a394b6653 /pkg | |
parent | efb51eee96331448d0b419ff9d981f11f22f7638 (diff) |
use wait groups when refreshing
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/commits_panel.go | 21 | ||||
-rw-r--r-- | pkg/gui/view_helpers.go | 29 |
2 files changed, 36 insertions, 14 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 27f709f1e..e0b904f5b 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -2,6 +2,7 @@ package gui import ( "strconv" + "sync" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands" @@ -75,15 +76,21 @@ func (gui *Gui) refreshCommits(g *gocui.Gui) error { return gui.createErrorPanel(gui.g, err.Error()) } - if err := gui.refreshCommitsWithLimit(); err != nil { - return gui.createErrorPanel(gui.g, err.Error()) - } + wg := sync.WaitGroup{} + wg.Add(2) - if err := gui.refreshReflogCommits(); err != nil { - return gui.createErrorPanel(gui.g, err.Error()) - } + go func() { + gui.refreshReflogCommits() + gui.refreshBranches() + wg.Done() + }() + + go func() { + gui.refreshCommitsWithLimit() + wg.Done() + }() - gui.refreshBranches() + wg.Wait() gui.refreshStatus() diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 254abd044..831facb84 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -4,6 +4,7 @@ import ( "fmt" "sort" "strings" + "sync" "github.com/go-errors/errors" "github.com/jesseduffield/gocui" @@ -14,14 +15,28 @@ import ( var cyclableViews = []string{"status", "files", "branches", "commits", "stash"} func (gui *Gui) refreshSidePanels(g *gocui.Gui) error { - if err := gui.refreshCommits(g); err != nil { - return err - } - if err := gui.refreshFiles(); err != nil { - return err - } + wg := sync.WaitGroup{} + + wg.Add(3) - return gui.refreshStashEntries(g) + func() { + gui.refreshCommits(g) + wg.Done() + }() + + func() { + gui.refreshFiles() + wg.Done() + }() + + func() { + gui.refreshStashEntries(g) + wg.Done() + }() + + wg.Wait() + + return nil } func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error { |