rename wg to startupWG

This commit is contained in:
steven 2024-05-29 09:17:46 +08:00
parent 6a6bdab463
commit 6d6183762c
2 changed files with 13 additions and 14 deletions

View file

@ -220,7 +220,7 @@ func (ac *accountCache) maybeReload() {
ac.watcher.start()
ac.throttle.Reset(minReloadInterval)
ac.mu.Unlock()
ac.watcher.wg.Wait()
ac.watcher.startupWG.Wait()
ac.scanAccounts()
}

View file

@ -34,14 +34,14 @@ type watcher struct {
runEnded bool // set to true when runloop ends
starting bool // set to true prior to runloop starting
quit chan struct{}
wg sync.WaitGroup // wait for watcher loop to start
startupWG sync.WaitGroup // wait for watcher loop to start
}
func newWatcher(ac *accountCache) *watcher {
return &watcher{
ac: ac,
quit: make(chan struct{}),
wg: sync.WaitGroup{},
startupWG: sync.WaitGroup{},
}
}
@ -55,7 +55,7 @@ func (w *watcher) start() {
if w.starting || w.running {
return
}
w.wg.Add(1)
w.startupWG.Add(1)
w.starting = true
go w.loop()
}
@ -81,12 +81,11 @@ func (w *watcher) loop() {
return
}
defer watcher.Close()
if err := watcher.Add(w.ac.keydir); err != nil {
if !os.IsNotExist(err) {
logger.Warn("Failed to watch keystore folder", "err", err)
}
w.wg.Done()
w.startupWG.Done()
return
}
@ -110,7 +109,7 @@ func (w *watcher) loop() {
<-debounce.C
}
defer debounce.Stop()
w.wg.Done()
w.startupWG.Done()
for {
select {
case <-w.quit: