* FireQueueEmpty now checks if a measurable amount of time has passed, and if not it sleeps for a small amount of time. This throttles OnQueueEmpty calls where there is no callback or the callback is doing very little work

* Changed HandleQueueEmpty()'s Monitor.TryEnter() calls to locks. We want to take our time in this function and do all the work necessary, since returning too fast will induce a sleep anyways
This commit is contained in:
John Hurliman
2009-10-21 16:21:08 -07:00
parent 2752a3525c
commit b06f258319
3 changed files with 16 additions and 38 deletions

View File

@@ -535,14 +535,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
ThrottleOutPacketType type = (ThrottleOutPacketType)i;
QueueEmpty callback = OnQueueEmpty;
int start = Environment.TickCount;
if (callback != null)
{
try { callback(type); }
catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + type + ") threw an exception: " + e.Message, e); }
}
// HACK: Try spending some extra time here to slow down OnQueueEmpty calls
//System.Threading.Thread.Sleep(100);
// Make sure all queue empty calls take at least a measurable amount of time,
// otherwise we'll peg a CPU trying to fire these too fast
if (Environment.TickCount == start)
System.Threading.Thread.Sleep((int)m_udpServer.TickCountResolution);
m_onQueueEmptyRunning[i] = false;
}