aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs28
1 files changed, 23 insertions, 5 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>