mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
* 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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user