diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 24 |
1 files changed, 22 insertions, 2 deletions
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; | |||
41 | using Nini.Config; | 41 | using Nini.Config; |
42 | using OpenSim; | 42 | using OpenSim; |
43 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
44 | using System.Diagnostics; | ||
44 | 45 | ||
45 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
46 | using OpenSim.Region.Framework.Interfaces; | 47 | using 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) |