* minor: tidy up async sog deleter

0.6.0-stable
Justin Clarke Casey 2008-09-29 19:55:45 +00:00
parent 75b6011a24
commit 374947cf01
1 changed files with 18 additions and 19 deletions

View File

@ -29,6 +29,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.Timers;
using System.Threading;
using log4net;
using OpenMetaverse;
using OpenMetaverse.Packets;
@ -55,13 +56,16 @@ namespace OpenSim.Region.Environment.Scenes
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Timer m_inventoryTicker;
private System.Timers.Timer m_inventoryTicker = new System.Timers.Timer(2000);
private readonly Queue<DeleteToInventoryHolder> m_inventoryDeletes = new Queue<DeleteToInventoryHolder>();
private Scene m_scene;
public AsyncSceneObjectGroupDeleter(Scene scene)
{
m_scene = scene;
m_inventoryTicker.AutoReset = false;
m_inventoryTicker.Elapsed += InventoryRunDeleteTimer;
}
/// <summary>
@ -70,17 +74,8 @@ namespace OpenSim.Region.Environment.Scenes
public void DeleteToInventory(
DeRezObjectPacket DeRezPacket, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient,
EntityBase selectedEnt, bool permissionToDelete)
{
if (m_inventoryTicker != null)
{
m_inventoryTicker.Stop();
}
else
{
m_inventoryTicker = new Timer(2000);
m_inventoryTicker.AutoReset = false;
m_inventoryTicker.Elapsed += InventoryRunDeleteTimer;
}
lock (m_inventoryDeletes)
{
@ -104,10 +99,11 @@ namespace OpenSim.Region.Environment.Scenes
private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e)
{
m_log.Info("Starting inventory send loop");
while (InventoryDeQueueAndDelete() == true)
m_log.Debug("[SCENE]: Starting send to inventory loop");
while (InventoryDeQueueAndDelete())
{
m_log.Info("Returned item successfully, continuing...");
m_log.Debug("[SCENE]: Returned item successfully to inventory, continuing...");
}
}
@ -122,10 +118,13 @@ namespace OpenSim.Region.Environment.Scenes
int left = m_inventoryDeletes.Count;
if (left > 0)
{
m_log.InfoFormat("Sending deleted object to user's inventory, {0} item(s) remaining.", left);
m_log.DebugFormat(
"[SCENE]: Sending deleted object to user's inventory, {0} item(s) remaining.", left);
x = m_inventoryDeletes.Dequeue();
m_scene.DeleteToInventory(
x.DeRezPacket, x.selectedEnt, x.remoteClient, x.objectGroup, x.folderID, x.permissionToDelete);
return true;
}
}
@ -135,11 +134,11 @@ namespace OpenSim.Region.Environment.Scenes
// We can't put the object group details in here since the root part may have disappeared (which is where these sit).
// FIXME: This needs to be fixed.
m_log.ErrorFormat(
"[AGENT INVENTORY]: Queued deletion of scene object to agent {0} {1} failed: {2}",
"[SCENE]: Queued deletion of scene object to agent {0} {1} failed: {2}",
(x != null ? x.remoteClient.Name : "unavailable"), (x != null ? x.remoteClient.AgentId.ToString() : "unavailable"), e.ToString());
}
m_log.Info("No objects left in inventory delete queue.");
m_log.Debug("[SCENE]: No objects left in inventory delete queue.");
return false;
}
}