Refactor the packet scheduling out of ClientView. Add intelligent

resending, timeouts, packet discarding. Add notification event for
packet discarding. Add priority scheduling for packet queues.
Add outgoing duplicate detection facility. Correct packet sequencing.
Make provisions for automatic server side throttle adjustments (comes
in next installment)
This commit is contained in:
Melanie Thielker
2008-07-22 17:58:42 +00:00
parent b2b5675bd4
commit f112cebde2
13 changed files with 837 additions and 834 deletions

View File

@@ -32,9 +32,19 @@ namespace OpenSim.Framework
{
public class BlockingQueue<T>
{
private readonly Queue<T> m_pqueue = new Queue<T>();
private readonly Queue<T> m_queue = new Queue<T>();
private readonly object m_queueSync = new object();
public void PriorityEnqueue(T value)
{
lock (m_queueSync)
{
m_pqueue.Enqueue(value);
Monitor.Pulse(m_queueSync);
}
}
public void Enqueue(T value)
{
lock (m_queueSync)
@@ -48,11 +58,13 @@ namespace OpenSim.Framework
{
lock (m_queueSync)
{
if (m_queue.Count < 1)
if (m_queue.Count < 1 && m_pqueue.Count < 1)
{
Monitor.Wait(m_queueSync);
}
if(m_pqueue.Count > 0)
return m_pqueue.Dequeue();
return m_queue.Dequeue();
}
}
@@ -61,6 +73,8 @@ namespace OpenSim.Framework
{
lock (m_queueSync)
{
if(m_pqueue.Contains(item))
return true;
return m_queue.Contains(item);
}
}
@@ -69,7 +83,7 @@ namespace OpenSim.Framework
{
lock (m_queueSync)
{
return m_queue.Count;
return m_queue.Count+m_pqueue.Count;
}
}
@@ -81,4 +95,4 @@ namespace OpenSim.Framework
}
}
}
}
}