diff options
author | Melanie | 2009-10-01 21:08:17 +0100 |
---|---|---|
committer | Melanie | 2009-10-01 21:08:17 +0100 |
commit | 5e9da4daabc49250af9c0ec810b1290c74bad885 (patch) | |
tree | 532821dc84556e6f395545a027fdfcfddf7c8bda /OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs | |
parent | Fixing LLClientView memory leak (diff) | |
download | opensim-SC_OLD-5e9da4daabc49250af9c0ec810b1290c74bad885.zip opensim-SC_OLD-5e9da4daabc49250af9c0ec810b1290c74bad885.tar.gz opensim-SC_OLD-5e9da4daabc49250af9c0ec810b1290c74bad885.tar.bz2 opensim-SC_OLD-5e9da4daabc49250af9c0ec810b1290c74bad885.tar.xz |
Add OnQueueEmpty event to the packet layers. No user functinality yet
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs index 6dd0697..f08f1b6 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs | |||
@@ -105,6 +105,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
105 | 105 | ||
106 | private UUID m_agentId; | 106 | private UUID m_agentId; |
107 | 107 | ||
108 | public event QueueEmpty OnQueueEmpty; | ||
109 | |||
108 | public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings) | 110 | public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings) |
109 | { | 111 | { |
110 | // While working on this, the BlockingQueue had me fooled for a bit. | 112 | // While working on this, the BlockingQueue had me fooled for a bit. |
@@ -293,30 +295,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
293 | if (LandOutgoingPacketQueue.Count > 0) | 295 | if (LandOutgoingPacketQueue.Count > 0) |
294 | { | 296 | { |
295 | SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue()); | 297 | SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue()); |
298 | TriggerOnQueueEmpty(ThrottleOutPacketType.Land); | ||
296 | } | 299 | } |
297 | if (WindOutgoingPacketQueue.Count > 0) | 300 | if (WindOutgoingPacketQueue.Count > 0) |
298 | { | 301 | { |
299 | SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue()); | 302 | SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue()); |
303 | TriggerOnQueueEmpty(ThrottleOutPacketType.Wind); | ||
300 | } | 304 | } |
301 | if (CloudOutgoingPacketQueue.Count > 0) | 305 | if (CloudOutgoingPacketQueue.Count > 0) |
302 | { | 306 | { |
303 | SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue()); | 307 | SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue()); |
308 | TriggerOnQueueEmpty(ThrottleOutPacketType.Cloud); | ||
304 | } | 309 | } |
310 | bool tasksSent = false; | ||
305 | if (TaskOutgoingPacketQueue.Count > 0) | 311 | if (TaskOutgoingPacketQueue.Count > 0) |
306 | { | 312 | { |
313 | tasksSent = true; | ||
307 | SendQueue.PriorityEnqueue(TaskOutgoingPacketQueue.Dequeue()); | 314 | SendQueue.PriorityEnqueue(TaskOutgoingPacketQueue.Dequeue()); |
308 | } | 315 | } |
309 | if (TaskLowpriorityPacketQueue.Count > 0) | 316 | if (TaskLowpriorityPacketQueue.Count > 0) |
310 | { | 317 | { |
318 | tasksSent = true; | ||
311 | SendQueue.Enqueue(TaskLowpriorityPacketQueue.Dequeue()); | 319 | SendQueue.Enqueue(TaskLowpriorityPacketQueue.Dequeue()); |
312 | } | 320 | } |
321 | if (tasksSent) | ||
322 | { | ||
323 | TriggerOnQueueEmpty(ThrottleOutPacketType.Task); | ||
324 | } | ||
313 | if (TextureOutgoingPacketQueue.Count > 0) | 325 | if (TextureOutgoingPacketQueue.Count > 0) |
314 | { | 326 | { |
315 | SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue()); | 327 | SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue()); |
328 | TriggerOnQueueEmpty(ThrottleOutPacketType.Texture); | ||
316 | } | 329 | } |
317 | if (AssetOutgoingPacketQueue.Count > 0) | 330 | if (AssetOutgoingPacketQueue.Count > 0) |
318 | { | 331 | { |
319 | SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue()); | 332 | SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue()); |
333 | TriggerOnQueueEmpty(ThrottleOutPacketType.Asset); | ||
320 | } | 334 | } |
321 | } | 335 | } |
322 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); | 336 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); |
@@ -405,6 +419,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
405 | bool qchanged = true; | 419 | bool qchanged = true; |
406 | 420 | ||
407 | ResetCounters(); | 421 | ResetCounters(); |
422 | |||
423 | List<ThrottleOutPacketType> Empty = new List<ThrottleOutPacketType>(); | ||
408 | // m_log.Info("[THROTTLE]: Entering Throttle"); | 424 | // m_log.Info("[THROTTLE]: Entering Throttle"); |
409 | while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops) | 425 | while (TotalThrottle.UnderLimit() && qchanged && throttleLoops <= MaxThrottleLoops) |
410 | { | 426 | { |
@@ -431,6 +447,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
431 | TotalThrottle.AddBytes(qpack.Length); | 447 | TotalThrottle.AddBytes(qpack.Length); |
432 | LandThrottle.AddBytes(qpack.Length); | 448 | LandThrottle.AddBytes(qpack.Length); |
433 | qchanged = true; | 449 | qchanged = true; |
450 | |||
451 | if (LandOutgoingPacketQueue.Count == 0) | ||
452 | Empty.Add(ThrottleOutPacketType.Land); | ||
434 | } | 453 | } |
435 | 454 | ||
436 | if ((WindOutgoingPacketQueue.Count > 0) && WindThrottle.UnderLimit()) | 455 | if ((WindOutgoingPacketQueue.Count > 0) && WindThrottle.UnderLimit()) |
@@ -441,6 +460,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
441 | TotalThrottle.AddBytes(qpack.Length); | 460 | TotalThrottle.AddBytes(qpack.Length); |
442 | WindThrottle.AddBytes(qpack.Length); | 461 | WindThrottle.AddBytes(qpack.Length); |
443 | qchanged = true; | 462 | qchanged = true; |
463 | |||
464 | if (WindOutgoingPacketQueue.Count == 0) | ||
465 | Empty.Add(ThrottleOutPacketType.Wind); | ||
444 | } | 466 | } |
445 | 467 | ||
446 | if ((CloudOutgoingPacketQueue.Count > 0) && CloudThrottle.UnderLimit()) | 468 | if ((CloudOutgoingPacketQueue.Count > 0) && CloudThrottle.UnderLimit()) |
@@ -451,6 +473,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
451 | TotalThrottle.AddBytes(qpack.Length); | 473 | TotalThrottle.AddBytes(qpack.Length); |
452 | CloudThrottle.AddBytes(qpack.Length); | 474 | CloudThrottle.AddBytes(qpack.Length); |
453 | qchanged = true; | 475 | qchanged = true; |
476 | |||
477 | if (CloudOutgoingPacketQueue.Count == 0) | ||
478 | Empty.Add(ThrottleOutPacketType.Cloud); | ||
454 | } | 479 | } |
455 | 480 | ||
456 | if ((TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) && TaskThrottle.UnderLimit()) | 481 | if ((TaskOutgoingPacketQueue.Count > 0 || TaskLowpriorityPacketQueue.Count > 0) && TaskThrottle.UnderLimit()) |
@@ -470,6 +495,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
470 | TotalThrottle.AddBytes(qpack.Length); | 495 | TotalThrottle.AddBytes(qpack.Length); |
471 | TaskThrottle.AddBytes(qpack.Length); | 496 | TaskThrottle.AddBytes(qpack.Length); |
472 | qchanged = true; | 497 | qchanged = true; |
498 | |||
499 | if (TaskOutgoingPacketQueue.Count == 0 && TaskLowpriorityPacketQueue.Count == 0) | ||
500 | Empty.Add(ThrottleOutPacketType.Task); | ||
473 | } | 501 | } |
474 | 502 | ||
475 | if ((TextureOutgoingPacketQueue.Count > 0) && TextureThrottle.UnderLimit()) | 503 | if ((TextureOutgoingPacketQueue.Count > 0) && TextureThrottle.UnderLimit()) |
@@ -480,6 +508,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
480 | TotalThrottle.AddBytes(qpack.Length); | 508 | TotalThrottle.AddBytes(qpack.Length); |
481 | TextureThrottle.AddBytes(qpack.Length); | 509 | TextureThrottle.AddBytes(qpack.Length); |
482 | qchanged = true; | 510 | qchanged = true; |
511 | |||
512 | if (TextureOutgoingPacketQueue.Count == 0) | ||
513 | Empty.Add(ThrottleOutPacketType.Texture); | ||
483 | } | 514 | } |
484 | 515 | ||
485 | if ((AssetOutgoingPacketQueue.Count > 0) && AssetThrottle.UnderLimit()) | 516 | if ((AssetOutgoingPacketQueue.Count > 0) && AssetThrottle.UnderLimit()) |
@@ -490,12 +521,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
490 | TotalThrottle.AddBytes(qpack.Length); | 521 | TotalThrottle.AddBytes(qpack.Length); |
491 | AssetThrottle.AddBytes(qpack.Length); | 522 | AssetThrottle.AddBytes(qpack.Length); |
492 | qchanged = true; | 523 | qchanged = true; |
524 | |||
525 | if (AssetOutgoingPacketQueue.Count == 0) | ||
526 | Empty.Add(ThrottleOutPacketType.Asset); | ||
493 | } | 527 | } |
494 | } | 528 | } |
495 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); | 529 | // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); |
530 | |||
531 | foreach (ThrottleOutPacketType t in Empty) | ||
532 | { | ||
533 | TriggerOnQueueEmpty(t); | ||
534 | } | ||
496 | } | 535 | } |
497 | } | 536 | } |
498 | 537 | ||
538 | private void TriggerOnQueueEmpty(ThrottleOutPacketType queue) | ||
539 | { | ||
540 | QueueEmpty handlerQueueEmpty = OnQueueEmpty; | ||
541 | |||
542 | if (handlerQueueEmpty == null) | ||
543 | return; | ||
544 | |||
545 | handlerQueueEmpty(queue); | ||
546 | } | ||
547 | |||
499 | private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) | 548 | private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) |
500 | { | 549 | { |
501 | // just to change the signature, and that ProcessThrottle | 550 | // just to change the signature, and that ProcessThrottle |