Save some cycles when message queues aren't that large.

pull/156/head v0.5b2
Christopher Young 2015-12-21 00:05:47 -05:00
rodzic 72d989ed3b
commit e6ad9aa830
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -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 {
@ -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)