Skip to content

Commit

Permalink
Save some cycles when message queues aren't that large.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyoung committed Dec 21, 2015
1 parent 72d989e commit e6ad9aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func refreshConnectedClients() {

func messageQueueSender() {
secondTimer := time.NewTicker(5 * time.Second)
queueTimer := time.NewTicker(1 * time.Second)
queueTimer := time.NewTicker(100 * time.Millisecond)

var lastQueueTimeChange time.Time // Reevaluate send frequency every 5 seconds.
for {
Expand Down Expand Up @@ -215,7 +215,7 @@ func messageQueueSender() {
averageSendableQueueSize = averageSendableQueueSize / float64(len(outSockets)) // It's a total, not an average, up until this point.
pd = math.Max(float64(1.0/2500.0), float64(1.0/(4.0*averageSendableQueueSize))) // Say 250ms is enough to get through the whole queue.
} else {
pd = float64(1.0 / 2500.0)
pd = float64(1.0 / 0.1) // 100ms.
}
queueTimer.Stop()
queueTimer = time.NewTicker(time.Duration(pd*1000000000.0) * time.Nanosecond)
Expand Down

0 comments on commit e6ad9aa

Please sign in to comment.