* 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.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Timers; using System.Timers;
using System.Threading;
using log4net; using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
@ -55,13 +56,16 @@ namespace OpenSim.Region.Environment.Scenes
private static readonly ILog m_log private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); = 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 readonly Queue<DeleteToInventoryHolder> m_inventoryDeletes = new Queue<DeleteToInventoryHolder>();
private Scene m_scene; private Scene m_scene;
public AsyncSceneObjectGroupDeleter(Scene scene) public AsyncSceneObjectGroupDeleter(Scene scene)
{ {
m_scene = scene; m_scene = scene;
m_inventoryTicker.AutoReset = false;
m_inventoryTicker.Elapsed += InventoryRunDeleteTimer;
} }
/// <summary> /// <summary>
@ -70,17 +74,8 @@ namespace OpenSim.Region.Environment.Scenes
public void DeleteToInventory( public void DeleteToInventory(
DeRezObjectPacket DeRezPacket, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient, DeRezObjectPacket DeRezPacket, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient,
EntityBase selectedEnt, bool permissionToDelete) EntityBase selectedEnt, bool permissionToDelete)
{
if (m_inventoryTicker != null)
{ {
m_inventoryTicker.Stop(); m_inventoryTicker.Stop();
}
else
{
m_inventoryTicker = new Timer(2000);
m_inventoryTicker.AutoReset = false;
m_inventoryTicker.Elapsed += InventoryRunDeleteTimer;
}
lock (m_inventoryDeletes) lock (m_inventoryDeletes)
{ {
@ -104,10 +99,11 @@ namespace OpenSim.Region.Environment.Scenes
private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e)
{ {
m_log.Info("Starting inventory send loop"); m_log.Debug("[SCENE]: Starting send to inventory loop");
while (InventoryDeQueueAndDelete() == true)
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; int left = m_inventoryDeletes.Count;
if (left > 0) 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(); x = m_inventoryDeletes.Dequeue();
m_scene.DeleteToInventory( m_scene.DeleteToInventory(
x.DeRezPacket, x.selectedEnt, x.remoteClient, x.objectGroup, x.folderID, x.permissionToDelete); x.DeRezPacket, x.selectedEnt, x.remoteClient, x.objectGroup, x.folderID, x.permissionToDelete);
return true; 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). // 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. // FIXME: This needs to be fixed.
m_log.ErrorFormat( 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()); (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; return false;
} }
} }