Make QueuePacket() lock free. Eliminates an unneeded lock()

0.6.0-stable
Melanie Thielker 2008-07-22 22:49:13 +00:00
parent 7fb103d374
commit e09ff343fb
1 changed files with 16 additions and 19 deletions

View File

@ -251,27 +251,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
// Add acks to outgoing packets // Add acks to outgoing packets
// //
lock(m_PendingAcks) if(m_PendingAcks.Count > 0)
{ {
if(m_PendingAcks.Count > 0) int count = m_PendingAcks.Count;
{ if(count > 10)
int count = m_PendingAcks.Count; count = 10;
if(count > 10) packet.Header.AckList = new uint[count];
count = 10;
packet.Header.AckList = new uint[count];
int i = 0; int i = 0;
foreach (uint ack in new List<uint>(m_PendingAcks.Keys)) foreach (uint ack in new List<uint>(m_PendingAcks.Keys))
{ {
packet.Header.AckList[i] = ack; packet.Header.AckList[i] = ack;
i++; i++;
m_PendingAcks.Remove(ack); m_PendingAcks.Remove(ack);
if (i >= 10) // That is how much space there is if (i >= 10) // That is how much space there is
break; break;
} }
} }
}
packet.TickCount = System.Environment.TickCount; packet.TickCount = System.Environment.TickCount;