From 7f3bfa277b894b90e660badf5ee47e4d99ef102c Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Tue, 16 Sep 2008 16:37:16 +0000
Subject: * minor: method documentation
---
.../ScriptEngine/Interfaces/IScriptEngine.cs | 22 +++++--
.../ScriptEngine/Interfaces/IScriptInstance.cs | 8 +++
.../Api/Implementation/AsyncCommandManager.cs | 3 +
.../Shared/Api/Implementation/LSL_Api.cs | 6 +-
.../Api/Implementation/Plugins/Dataserver.cs | 4 +-
OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 11 ++--
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 17 +++++-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 68 +++++++++++++---------
8 files changed, 95 insertions(+), 44 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
index 43c2487..ba7e653 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
@@ -36,28 +36,40 @@ using Amib.Threading;
namespace OpenSim.Region.ScriptEngine.Interfaces
{
+ ///
+ /// An interface for a script API module to communicate with
+ /// the engine it's running under
+ ///
public interface IScriptEngine
{
- //
- // An interface for a script API module to communicate with
- // the engine it's running under
- //
-
Scene World { get; }
IConfig Config { get; }
Object AsyncCommands { get; }
ILog Log { get; }
string ScriptEngineName { get; }
+ ///
+ /// Post an event to a single script
+ ///
bool PostScriptEvent(UUID itemID, EventParams parms);
+
+ ///
+ /// Post event to an entire prim
+ ///
bool PostObjectEvent(uint localID, EventParams parms);
+
void ApiResetScript(UUID itemID);
void ResetScript(UUID itemID);
void SetScriptState(UUID itemID, bool state);
bool GetScriptState(UUID itemID);
void SetState(UUID itemID, string newState);
int GetStartParameter(UUID itemID);
+
+ ///
+ /// Queue an event for execution
+ ///
IScriptWorkItem QueueEventHandler(object parms);
+
IScriptApi GetApi(UUID itemID, string name);
DetectParams GetDetectParams(UUID item, int number);
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index 169955c..a05edbd 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -50,6 +50,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
bool Wait(TimeSpan t);
}
+ ///
+ /// Interface for interaction with a particular script instance
+ ///
public interface IScriptInstance
{
bool Running { get; set; }
@@ -75,6 +78,11 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
void SetState(string state);
void PostEvent(EventParams data);
+
+ ///
+ /// Process the next event queued for this script
+ ///
+ ///
object EventProcessor();
int EventTime();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 93a1a80..f331b5c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -149,6 +149,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ ///
+ /// Main loop for the manager thread
+ ///
private static void CmdHandlerThreadLoop()
{
while (true)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index a5ff42d..d6c33f6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
///
public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi
{
- // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
internal IScriptEngine m_ScriptEngine;
internal SceneObjectPart m_host;
@@ -7925,7 +7925,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
public LSL_Types.LSLString llGetNotecardLine(string name, int line)
- {
+ {
m_host.AddScriptLPS(1);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
@@ -7935,6 +7935,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID,
m_itemID, item.AssetID.ToString());
+
if (NotecardCache.IsCached(item.AssetID))
{
AsyncCommands.
@@ -7943,6 +7944,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// ScriptSleep(100);
return tid.ToString();
}
+
WithNotecard(item.AssetID, delegate (UUID id, AssetBase a)
{
System.Text.ASCIIEncoding enc =
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs
index 7300f10..9676cb3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
ds.startTime = DateTime.Now;
- DataserverRequests[identifier]=ds;
+ DataserverRequests[identifier] = ds;
return ds.ID;
}
@@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
if (!DataserverRequests.ContainsKey(identifier))
return;
- ds=DataserverRequests[identifier];
+ ds = DataserverRequests[identifier];
DataserverRequests.Remove(identifier);
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
index 8599e06..14266dd 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -161,17 +161,20 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
+ ///
+ /// Holds all the data required to execute a scripting event.
+ ///
public class EventParams
{
public EventParams(string eventName, Object[] eventParams, DetectParams[] detectParams)
{
- EventName=eventName;
- Params=eventParams;
- DetectParams=detectParams;
+ EventName = eventName;
+ Params = eventParams;
+ DetectParams = detectParams;
}
public string EventName;
public Object[] Params;
public DetectParams[] DetectParams;
}
-}
+}
\ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 8f6108d..da55858 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -35,7 +35,7 @@ using System.Reflection;
using System.Globalization;
using System.Xml;
using OpenMetaverse;
-using log4net;
+//using log4net;
using Nini.Config;
using Amib.Threading;
using OpenSim.Framework;
@@ -52,8 +52,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
public class ScriptInstance : IScriptInstance
{
+ //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
private IScriptEngine m_Engine;
- private IScriptWorkItem m_CurrentResult=null;
+ private IScriptWorkItem m_CurrentResult = null;
private Queue m_EventQueue = new Queue(32);
private bool m_RunEvents = false;
private UUID m_ItemID;
@@ -455,6 +457,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
}
+ ///
+ /// Process the next event queued for this script
+ ///
+ ///
public object EventProcessor()
{
EventParams data = null;
@@ -470,6 +476,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (data.EventName == "timer")
m_TimerQueued = false;
}
+
+ //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
m_DetectParams = data.DetectParams;
@@ -721,5 +729,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
return m_Apis[name];
return null;
}
+
+ public override string ToString()
+ {
+ return String.Format("{0} {1} on {2}", m_ScriptName, m_ItemID, m_PrimName);
+ }
}
}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 0dc1ade..f27a144 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -173,24 +173,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine
ThreadPriority prio = ThreadPriority.BelowNormal;
switch (priority)
{
- case "Lowest":
- prio = ThreadPriority.Lowest;
- break;
- case "BelowNormal":
- prio = ThreadPriority.BelowNormal;
- break;
- case "Normal":
- prio = ThreadPriority.Normal;
- break;
- case "AboveNormal":
- prio = ThreadPriority.AboveNormal;
- break;
- case "Highest":
- prio = ThreadPriority.Highest;
- break;
- default:
- m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority);
- break;
+ case "Lowest":
+ prio = ThreadPriority.Lowest;
+ break;
+ case "BelowNormal":
+ prio = ThreadPriority.BelowNormal;
+ break;
+ case "Normal":
+ prio = ThreadPriority.Normal;
+ break;
+ case "AboveNormal":
+ prio = ThreadPriority.AboveNormal;
+ break;
+ case "Highest":
+ prio = ThreadPriority.Highest;
+ break;
+ default:
+ m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority);
+ break;
}
lock (m_ScriptEngines)
@@ -659,24 +659,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return new XWorkItem(m_ThreadPool.QueueWorkItem(
new WorkItemCallback(this.ProcessEventHandler),
parms));
- }
-
- //
- // The main script engine worker
- //
+ }
+
+ ///
+ /// Process a previously posted script event.
+ ///
+ ///
+ ///
private object ProcessEventHandler(object parms)
{
CultureInfo USCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = USCulture;
IScriptInstance instance = (ScriptInstance) parms;
+
+ //m_log.DebugFormat("[XENGINE]: Processing event for {0}", instance);
return instance.EventProcessor();
}
- //
- // Post event to an entire prim
- //
+ ///
+ /// Post event to an entire prim
+ ///
+ ///
+ ///
+ ///
public bool PostObjectEvent(uint localID, EventParams p)
{
bool result = false;
@@ -699,9 +706,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return result;
}
- //
- // Post an event to a single script
- //
+ ///
+ /// Post an event to a single script
+ ///
+ ///
+ ///
+ ///
public bool PostScriptEvent(UUID itemID, EventParams p)
{
if (m_Scripts.ContainsKey(itemID))
--
cgit v1.1