From a57a472ab8edf70430a8391909e6078b9ae0f26d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 00:51:59 +0100 Subject: Add proper method doc and comments to m_dataPresentEvent (from d9d9959) --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 0e9f1b7..37fd252 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -223,6 +223,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Flag to signal when clients should send pings protected bool m_sendPing; + /// + /// Event used to signal when queued packets are available for sending. + /// + /// + /// This allows the outbound loop to only operate when there is data to send rather than continuously polling. + /// Some data is sent immediately and not queued. That data would not trigger this event. + /// + private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); + private Pool m_incomingPacketPool; /// @@ -881,11 +890,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP } PacketPool.Instance.ReturnPacket(packet); + m_dataPresentEvent.Set(); } - private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); - /// /// Start the process of sending a packet to the client. /// @@ -1817,6 +1825,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP // token bucket could get more tokens //if (!m_packetSent) // Thread.Sleep((int)TickCountResolution); + // + // Instead, now wait for data present to be explicitly signalled. Evidence so far is that with + // modern mono it reduces CPU base load since there is no more continuous polling. m_dataPresentEvent.WaitOne(100); Watchdog.UpdateThread(); -- cgit v1.1