WIP: improve responsiveness.
This commit is contained in:
10
peer/app.go
10
peer/app.go
@@ -78,8 +78,8 @@ func (a *App) Run() error {
|
||||
// while we were down).
|
||||
a.updateHosts()
|
||||
|
||||
ticker := time.NewTicker(PingInterval)
|
||||
defer ticker.Stop()
|
||||
stateTicker := time.NewTicker(time.Second) // TODO: Const.
|
||||
pingTicker := time.NewTicker(PingInterval)
|
||||
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, syscall.SIGTERM, syscall.SIGINT)
|
||||
@@ -97,10 +97,12 @@ func (a *App) Run() error {
|
||||
a.onPing(e)
|
||||
case e := <-a.multicastCh:
|
||||
a.onMulticastDiscovery(e)
|
||||
case <-ticker.C:
|
||||
case <-stateTicker.C:
|
||||
a.onTick()
|
||||
case <-pingTicker.C:
|
||||
a.onPingTicker()
|
||||
tickCount++
|
||||
if tickCount%8 == 0 {
|
||||
if tickCount == 0 {
|
||||
a.logNetworkState()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user