Skip to content

Commit 5ee5d42

Browse files
committed
Instantiate Mutexes's fields by value
Instead, pass the entire Mutexes struct by pointer to controllers. This is better because Mutexes now has a zero value and doesn't need to be initialized.
1 parent 4c92ffd commit 5ee5d42

File tree

3 files changed

+12
-25
lines changed

3 files changed

+12
-25
lines changed

pkg/gui/gui.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -681,17 +681,6 @@ func NewGui(
681681
// real value after loading the user config:
682682
ShowExtrasWindow: true,
683683

684-
Mutexes: types.Mutexes{
685-
RefreshingFilesMutex: &deadlock.Mutex{},
686-
RefreshingBranchesMutex: &deadlock.Mutex{},
687-
RefreshingStatusMutex: &deadlock.Mutex{},
688-
LocalCommitsMutex: &deadlock.Mutex{},
689-
SubCommitsMutex: &deadlock.Mutex{},
690-
AuthorsMutex: &deadlock.Mutex{},
691-
SubprocessMutex: &deadlock.Mutex{},
692-
PopupMutex: &deadlock.Mutex{},
693-
PtyMutex: &deadlock.Mutex{},
694-
},
695684
InitialDir: initialDir,
696685
afterLayoutFuncs: make(chan func() error, 1000),
697686

pkg/gui/gui_common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ func (self *guiCommon) Model() *types.Model {
100100
return self.gui.State.Model
101101
}
102102

103-
func (self *guiCommon) Mutexes() types.Mutexes {
104-
return self.gui.Mutexes
103+
func (self *guiCommon) Mutexes() *types.Mutexes {
104+
return &self.gui.Mutexes
105105
}
106106

107107
func (self *guiCommon) GocuiGui() *gocui.Gui {

pkg/gui/types/common.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ type IGuiCommon interface {
9494

9595
Modes() *Modes
9696

97-
Mutexes() Mutexes
97+
Mutexes() *Mutexes
9898

9999
State() IStateAccessor
100100

@@ -313,18 +313,16 @@ type Model struct {
313313
HashPool *utils.StringPool
314314
}
315315

316-
// if you add a new mutex here be sure to instantiate it. We're using pointers to
317-
// mutexes so that we can pass the mutexes to controllers.
318316
type Mutexes struct {
319-
RefreshingFilesMutex *deadlock.Mutex
320-
RefreshingBranchesMutex *deadlock.Mutex
321-
RefreshingStatusMutex *deadlock.Mutex
322-
LocalCommitsMutex *deadlock.Mutex
323-
SubCommitsMutex *deadlock.Mutex
324-
AuthorsMutex *deadlock.Mutex
325-
SubprocessMutex *deadlock.Mutex
326-
PopupMutex *deadlock.Mutex
327-
PtyMutex *deadlock.Mutex
317+
RefreshingFilesMutex deadlock.Mutex
318+
RefreshingBranchesMutex deadlock.Mutex
319+
RefreshingStatusMutex deadlock.Mutex
320+
LocalCommitsMutex deadlock.Mutex
321+
SubCommitsMutex deadlock.Mutex
322+
AuthorsMutex deadlock.Mutex
323+
SubprocessMutex deadlock.Mutex
324+
PopupMutex deadlock.Mutex
325+
PtyMutex deadlock.Mutex
328326
}
329327

330328
// A long-running operation associated with an item. For example, we'll show

0 commit comments

Comments
 (0)