Cut client latency by attempting to send upstream messages

immediately.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5592 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2008-12-10 21:41:10 +00:00
parent 20b775a41b
commit df5f5ace27
@@ -76,10 +76,13 @@ public class Communicator
public function postMessage (msg :UpstreamMessage) :void
{
if (_writer == null) {
_outq.push(msg);
if (_writer != null) {
sendPendingMessages(null);
} else {
log.warning("Posting message prior to opening socket", "msg", msg);
}
_outq.push(msg);
}
/**
@@ -173,15 +176,14 @@ public class Communicator
while (_outq.length > 0) {
// if we've exceeded our throttle, stop for now
if (_client.getOutgoingMessageThrottle().throttleOp()) {
if (_tqsize != _outq.length) {
// only log when our outq size changes
_tqsize = _outq.length;
if (!_notedThrottle) {
log.info("Throttling outgoing messages", "queue", _outq.length,
"throttle", _client.getOutgoingMessageThrottle());
_notedThrottle = true;
}
return;
}
_tqsize = 0;
_notedThrottle = false;
// grab the next message from the queue and send it
var msg :UpstreamMessage = (_outq.shift() as UpstreamMessage);
@@ -356,7 +358,7 @@ public class Communicator
protected var _outq :Array = new Array();
protected var _writer :Timer;
protected var _tqsize :int = 0;
protected var _notedThrottle :Boolean = false;
protected const log :Log = Log.getLog(this);