aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs24
4 files changed, 51 insertions, 9 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fa762a6..7521ea6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -104,6 +104,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
104 WaitHandle m_coopSleepHandle; 104 WaitHandle m_coopSleepHandle;
105 105
106 /// <summary> 106 /// <summary>
107 /// The timer used by the ScriptInstance to measure how long the script has executed.
108 /// </summary>
109 private Stopwatch m_executionTimer;
110
111 /// <summary>
107 /// The item that hosts this script 112 /// The item that hosts this script
108 /// </summary> 113 /// </summary>
109 protected TaskInventoryItem m_item; 114 protected TaskInventoryItem m_item;
@@ -262,12 +267,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
262 }; 267 };
263 268
264 public void Initialize( 269 public void Initialize(
265 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) 270 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle,
271 Stopwatch executionTimer)
266 { 272 {
267 m_ScriptEngine = scriptEngine; 273 m_ScriptEngine = scriptEngine;
268 m_host = host; 274 m_host = host;
269 m_item = item; 275 m_item = item;
270 m_coopSleepHandle = coopSleepHandle; 276 m_coopSleepHandle = coopSleepHandle;
277 m_executionTimer = executionTimer;
271 278
272 LoadConfig(); 279 LoadConfig();
273 280
@@ -406,10 +413,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
406 413
407 protected virtual void Sleep(int delay) 414 protected virtual void Sleep(int delay)
408 { 415 {
409 if (m_coopSleepHandle == null) 416 if (m_executionTimer != null)
410 System.Threading.Thread.Sleep(delay); 417 m_executionTimer.Stop(); // sleep time doesn't count as execution time, since it doesn't use the CPU
411 else 418
412 CheckForCoopTermination(delay); 419 try
420 {
421 if (m_coopSleepHandle == null)
422 System.Threading.Thread.Sleep(delay);
423 else
424 CheckForCoopTermination(delay);
425 }
426 finally
427 {
428 if (m_executionTimer != null)
429 m_executionTimer.Start();
430 }
413 } 431 }
414 432
415 /// <summary> 433 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 3406aea..9bb12d3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -51,6 +51,7 @@ using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; 51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; 53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
54using System.Diagnostics;
54 55
55namespace OpenSim.Region.ScriptEngine.Shared.Api 56namespace OpenSim.Region.ScriptEngine.Shared.Api
56{ 57{
@@ -63,7 +64,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
63 internal IScriptModuleComms m_comms = null; 64 internal IScriptModuleComms m_comms = null;
64 65
65 public void Initialize( 66 public void Initialize(
66 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) 67 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle,
68 Stopwatch executionTimer)
67 { 69 {
68 m_ScriptEngine = scriptEngine; 70 m_ScriptEngine = scriptEngine;
69 m_host = host; 71 m_host = host;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 92dd813..39505e1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -51,6 +51,7 @@ using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; 51using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 52using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; 53using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
54using System.Diagnostics;
54 55
55namespace OpenSim.Region.ScriptEngine.Shared.Api 56namespace OpenSim.Region.ScriptEngine.Shared.Api
56{ 57{
@@ -66,7 +67,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
66 internal IScriptModuleComms m_comms = null; 67 internal IScriptModuleComms m_comms = null;
67 68
68 public void Initialize( 69 public void Initialize(
69 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) 70 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle,
71 Stopwatch executionTimer)
70 { 72 {
71 m_ScriptEngine = scriptEngine; 73 m_ScriptEngine = scriptEngine;
72 m_host = host; 74 m_host = host;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 123f8ca..4bb0b74 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -41,6 +41,7 @@ using OpenMetaverse.StructuredData;
41using Nini.Config; 41using Nini.Config;
42using OpenSim; 42using OpenSim;
43using OpenSim.Framework; 43using OpenSim.Framework;
44using System.Diagnostics;
44 45
45using OpenSim.Framework.Console; 46using OpenSim.Framework.Console;
46using OpenSim.Region.Framework.Interfaces; 47using OpenSim.Region.Framework.Interfaces;
@@ -142,14 +143,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
142 internal float m_ScriptDistanceFactor = 1.0f; 143 internal float m_ScriptDistanceFactor = 1.0f;
143 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 144 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
144 145
146 /// <summary>
147 /// The timer used by the ScriptInstance to measure how long the script has executed.
148 /// </summary>
149 private Stopwatch m_executionTimer;
150
145 protected IUrlModule m_UrlModule = null; 151 protected IUrlModule m_UrlModule = null;
146 152
147 public void Initialize( 153 public void Initialize(
148 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) 154 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle,
155 Stopwatch executionTimer)
149 { 156 {
150 m_ScriptEngine = scriptEngine; 157 m_ScriptEngine = scriptEngine;
151 m_host = host; 158 m_host = host;
152 m_item = item; 159 m_item = item;
160 m_executionTimer = executionTimer;
153 161
154 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); 162 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
155 163
@@ -432,7 +440,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
432 delay = (int)((float)delay * m_ScriptDelayFactor); 440 delay = (int)((float)delay * m_ScriptDelayFactor);
433 if (delay == 0) 441 if (delay == 0)
434 return; 442 return;
435 System.Threading.Thread.Sleep(delay); 443
444 if (m_executionTimer != null)
445 m_executionTimer.Stop(); // sleep time doesn't count as execution time, since it doesn't use the CPU
446
447 try
448 {
449 System.Threading.Thread.Sleep(delay);
450 }
451 finally
452 {
453 if (m_executionTimer != null)
454 m_executionTimer.Start();
455 }
436 } 456 }
437 457
438 public LSL_Integer osSetTerrainHeight(int x, int y, double val) 458 public LSL_Integer osSetTerrainHeight(int x, int y, double val)