From 9f2d1e9294f7f183e52d0cc5d98c8231e0e55fca Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 20 May 2010 23:53:27 -0700 Subject: * Made PriorityQueue non-generic so it natively understands EntityUpdate structs * Replaced the per-avatar seen update tracking with update flag combining, to avoid overwriting full updates with terse updates --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 70 ++++++++++------------ 1 file changed, 32 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index cf78266..c8a542b 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -324,8 +324,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private readonly IGroupsModule m_GroupsModule; private int m_cachedTextureSerial; - private PriorityQueue m_entityUpdates; - private Dictionary m_seenPrims = new Dictionary(); + private PriorityQueue m_entityUpdates; /// /// List used in construction of data blocks for an object update packet. This is to stop us having to @@ -436,7 +435,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_scene = scene; - m_entityUpdates = new PriorityQueue(m_scene.Entities.Count); + m_entityUpdates = new PriorityQueue(m_scene.Entities.Count); m_fullUpdateDataBlocksBuilder = new List(); m_killRecord = new HashSet(); @@ -3499,14 +3498,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP { canUseCompressed = false; } - else - { - if (!m_seenPrims.ContainsKey(((SceneObjectPart)update.Entity).LocalId)) - { - updateFlags = PrimUpdateFlags.FullUpdate; - m_seenPrims[((SceneObjectPart)update.Entity).LocalId] = true; - } - } if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate)) { @@ -3626,7 +3617,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { //m_log.Debug("[CLIENT]: Reprioritizing prim updates for " + m_firstName + " " + m_lastName); - PriorityQueue.UpdatePriorityHandler update_priority_handler = + PriorityQueue.UpdatePriorityHandler update_priority_handler = delegate(ref double priority, uint local_id) { priority = handler(new UpdatePriorityData(priority, local_id)); @@ -11562,26 +11553,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP } #region PriorityQueue - public class PriorityQueue + public class PriorityQueue { - internal delegate bool UpdatePriorityHandler(ref TPriority priority, uint local_id); + internal delegate bool UpdatePriorityHandler(ref double priority, uint local_id); private MinHeap[] m_heaps = new MinHeap[1]; private Dictionary m_lookupTable; - private Comparison m_comparison; + private Comparison m_comparison; private object m_syncRoot = new object(); internal PriorityQueue() : - this(MinHeap.DEFAULT_CAPACITY, Comparer.Default) { } + this(MinHeap.DEFAULT_CAPACITY, Comparer.Default) { } internal PriorityQueue(int capacity) : - this(capacity, Comparer.Default) { } - internal PriorityQueue(IComparer comparer) : - this(new Comparison(comparer.Compare)) { } - internal PriorityQueue(Comparison comparison) : + this(capacity, Comparer.Default) { } + internal PriorityQueue(IComparer comparer) : + this(new Comparison(comparer.Compare)) { } + internal PriorityQueue(Comparison comparison) : this(MinHeap.DEFAULT_CAPACITY, comparison) { } - internal PriorityQueue(int capacity, IComparer comparer) : - this(capacity, new Comparison(comparer.Compare)) { } - internal PriorityQueue(int capacity, Comparison comparison) + internal PriorityQueue(int capacity, IComparer comparer) : + this(capacity, new Comparison(comparer.Compare)) { } + internal PriorityQueue(int capacity, Comparison comparison) { m_lookupTable = new Dictionary(capacity); @@ -11602,12 +11593,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - public bool Enqueue(TPriority priority, TValue value, uint local_id) + public bool Enqueue(double priority, EntityUpdate value, uint local_id) { LookupItem item; if (m_lookupTable.TryGetValue(local_id, out item)) { + // Combine flags + value.Flags |= item.Heap[item.Handle].Value.Flags; + item.Heap[item.Handle] = new MinHeapItem(priority, value, local_id, this.m_comparison); return false; } @@ -11620,7 +11614,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - internal TValue Peek() + internal EntityUpdate Peek() { for (int i = 0; i < m_heaps.Length; ++i) if (m_heaps[i].Count > 0) @@ -11628,7 +11622,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP throw new InvalidOperationException(string.Format("The {0} is empty", this.GetType().ToString())); } - internal bool TryDequeue(out TValue value) + internal bool TryDequeue(out EntityUpdate value) { for (int i = 0; i < m_heaps.Length; ++i) { @@ -11641,14 +11635,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - value = default(TValue); + value = default(EntityUpdate); return false; } internal void Reprioritize(UpdatePriorityHandler handler) { MinHeapItem item; - TPriority priority; + double priority; foreach (LookupItem lookup in new List(this.m_lookupTable.Values)) { @@ -11674,16 +11668,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region MinHeapItem private struct MinHeapItem : IComparable { - private TPriority priority; - private TValue value; + private double priority; + private EntityUpdate value; private uint local_id; - private Comparison comparison; + private Comparison comparison; - internal MinHeapItem(TPriority priority, TValue value, uint local_id) : - this(priority, value, local_id, Comparer.Default) { } - internal MinHeapItem(TPriority priority, TValue value, uint local_id, IComparer comparer) : - this(priority, value, local_id, new Comparison(comparer.Compare)) { } - internal MinHeapItem(TPriority priority, TValue value, uint local_id, Comparison comparison) + internal MinHeapItem(double priority, EntityUpdate value, uint local_id) : + this(priority, value, local_id, Comparer.Default) { } + internal MinHeapItem(double priority, EntityUpdate value, uint local_id, IComparer comparer) : + this(priority, value, local_id, new Comparison(comparer.Compare)) { } + internal MinHeapItem(double priority, EntityUpdate value, uint local_id, Comparison comparison) { this.priority = priority; this.value = value; @@ -11691,8 +11685,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP this.comparison = comparison; } - internal TPriority Priority { get { return this.priority; } } - internal TValue Value { get { return this.value; } } + internal double Priority { get { return this.priority; } } + internal EntityUpdate Value { get { return this.value; } } internal uint LocalID { get { return this.local_id; } } public override string ToString() -- cgit v1.1