try Hacking in an AutoResetEvent to control the outgoing UDP loop instead of a continuous loop with sleeps.

Does appear to have a cpu impact but may need further tweaking
This commit is contained in:
Justin Clark-Casey (justincc)
2013-07-18 01:17:46 +01:00
committed by Diva Canto
parent 71b1511db5
commit d9d995914c
2 changed files with 28 additions and 2 deletions

View File

@@ -806,8 +806,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
PacketPool.Instance.ReturnPacket(packet);
m_dataPresentEvent.Set();
}
private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false);
/// <summary>
/// Start the process of sending a packet to the client.
/// </summary>
@@ -1658,6 +1662,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// Action generic every round
Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler;
// while (true)
while (base.IsRunningOutbound)
{
try
@@ -1718,8 +1723,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// If nothing was sent, sleep for the minimum amount of time before a
// token bucket could get more tokens
if (!m_packetSent)
Thread.Sleep((int)TickCountResolution);
//if (!m_packetSent)
// Thread.Sleep((int)TickCountResolution);
m_dataPresentEvent.WaitOne(100);
Watchdog.UpdateThread();
}