diff options
Diffstat (limited to 'OpenSim/Framework/PriorityQueue.cs')
-rw-r--r-- | OpenSim/Framework/PriorityQueue.cs | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/OpenSim/Framework/PriorityQueue.cs b/OpenSim/Framework/PriorityQueue.cs index e7a7f7f..4f05f65 100644 --- a/OpenSim/Framework/PriorityQueue.cs +++ b/OpenSim/Framework/PriorityQueue.cs | |||
@@ -45,7 +45,8 @@ namespace OpenSim.Framework | |||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Total number of queues (priorities) available | 46 | /// Total number of queues (priorities) available |
47 | /// </summary> | 47 | /// </summary> |
48 | public const uint NumberOfQueues = 12; | 48 | |
49 | public const uint NumberOfQueues = 12; // includes immediate queues, m_queueCounts need to be set acording | ||
49 | 50 | ||
50 | /// <summary> | 51 | /// <summary> |
51 | /// Number of queuest (priorities) that are processed immediately | 52 | /// Number of queuest (priorities) that are processed immediately |
@@ -60,7 +61,10 @@ namespace OpenSim.Framework | |||
60 | // each pass. weighted towards the higher priority queues | 61 | // each pass. weighted towards the higher priority queues |
61 | private uint m_nextQueue = 0; | 62 | private uint m_nextQueue = 0; |
62 | private uint m_countFromQueue = 0; | 63 | private uint m_countFromQueue = 0; |
63 | private uint[] m_queueCounts = { 8, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1 }; | 64 | // first queues are imediate, so no counts |
65 | // private uint[] m_queueCounts = { 0, 0, 8, 4, 4, 2, 2, 2, 2, 1, 1, 1 }; | ||
66 | private uint[] m_queueCounts = {0, 0, 8, 8, 5, 4, 3, 2, 1, 1, 1, 1}; | ||
67 | // this is ava, ava, attach, <10m, 20,40,80,160m,320,640,1280, + | ||
64 | 68 | ||
65 | // next request is a counter of the number of updates queued, it provides | 69 | // next request is a counter of the number of updates queued, it provides |
66 | // a total ordering on the updates coming through the queue and is more | 70 | // a total ordering on the updates coming through the queue and is more |
@@ -130,6 +134,21 @@ namespace OpenSim.Framework | |||
130 | return true; | 134 | return true; |
131 | } | 135 | } |
132 | 136 | ||
137 | |||
138 | public void Remove(List<uint> ids) | ||
139 | { | ||
140 | LookupItem lookup; | ||
141 | |||
142 | foreach (uint localid in ids) | ||
143 | { | ||
144 | if (m_lookupTable.TryGetValue(localid, out lookup)) | ||
145 | { | ||
146 | lookup.Heap.Remove(lookup.Handle); | ||
147 | m_lookupTable.Remove(localid); | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | |||
133 | /// <summary> | 152 | /// <summary> |
134 | /// Remove an item from one of the queues. Specifically, it removes the | 153 | /// Remove an item from one of the queues. Specifically, it removes the |
135 | /// oldest item from the next queue in order to provide fair access to | 154 | /// oldest item from the next queue in order to provide fair access to |
@@ -137,7 +156,7 @@ namespace OpenSim.Framework | |||
137 | /// </summary> | 156 | /// </summary> |
138 | public bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) | 157 | public bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) |
139 | { | 158 | { |
140 | // If there is anything in priority queue 0, return it first no | 159 | // If there is anything in imediate queues, return it first no |
141 | // matter what else. Breaks fairness. But very useful. | 160 | // matter what else. Breaks fairness. But very useful. |
142 | for (int iq = 0; iq < NumberOfImmediateQueues; iq++) | 161 | for (int iq = 0; iq < NumberOfImmediateQueues; iq++) |
143 | { | 162 | { |
@@ -172,14 +191,13 @@ namespace OpenSim.Framework | |||
172 | } | 191 | } |
173 | 192 | ||
174 | // Find the next non-immediate queue with updates in it | 193 | // Find the next non-immediate queue with updates in it |
175 | for (int i = 0; i < NumberOfQueues; ++i) | 194 | for (uint i = NumberOfImmediateQueues; i < NumberOfQueues; ++i) |
176 | { | 195 | { |
177 | m_nextQueue = (uint)((m_nextQueue + 1) % NumberOfQueues); | 196 | m_nextQueue++; |
178 | m_countFromQueue = m_queueCounts[m_nextQueue]; | 197 | if(m_nextQueue >= NumberOfQueues) |
198 | m_nextQueue = NumberOfImmediateQueues; | ||
179 | 199 | ||
180 | // if this is one of the immediate queues, just skip it | 200 | m_countFromQueue = m_queueCounts[m_nextQueue]; |
181 | if (m_nextQueue < NumberOfImmediateQueues) | ||
182 | continue; | ||
183 | 201 | ||
184 | if (m_heaps[m_nextQueue].Count > 0) | 202 | if (m_heaps[m_nextQueue].Count > 0) |
185 | { | 203 | { |
@@ -189,7 +207,6 @@ namespace OpenSim.Framework | |||
189 | m_lookupTable.Remove(item.Value.Entity.LocalId); | 207 | m_lookupTable.Remove(item.Value.Entity.LocalId); |
190 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); | 208 | timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); |
191 | value = item.Value; | 209 | value = item.Value; |
192 | |||
193 | return true; | 210 | return true; |
194 | } | 211 | } |
195 | } | 212 | } |