From ee7debcca69d31573562dafead1f21d50931f632 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 17 Aug 2015 18:11:45 +0200 Subject: Revert "When scripts are sleeping, don't count that as execution time" The approach is good but the way it is written breaks the architecture. Rewrite follows. This reverts commit a568f06b7faea807149205d0e47454e4883e4836. --- .../Shared/Api/Implementation/LSL_Api.cs | 28 ++++------------------ .../Shared/Api/Implementation/LS_Api.cs | 4 +--- .../Shared/Api/Implementation/MOD_Api.cs | 4 +--- .../Shared/Api/Implementation/OSSL_Api.cs | 24 ++----------------- 4 files changed, 9 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b4a8620..946680c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -104,11 +104,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api WaitHandle m_coopSleepHandle; /// - /// The timer used by the ScriptInstance to measure how long the script has executed. - /// - private Stopwatch m_executionTimer; - - /// /// The item that hosts this script /// protected TaskInventoryItem m_item; @@ -267,14 +262,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api }; public void Initialize( - IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle, - Stopwatch executionTimer) + IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) { m_ScriptEngine = scriptEngine; m_host = host; m_item = item; m_coopSleepHandle = coopSleepHandle; - m_executionTimer = executionTimer; LoadConfig(); @@ -413,21 +406,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected virtual void Sleep(int delay) { - if (m_executionTimer != null) - m_executionTimer.Stop(); // sleep time doesn't count as execution time, since it doesn't use the CPU - - try - { - if (m_coopSleepHandle == null) - System.Threading.Thread.Sleep(delay); - else - CheckForCoopTermination(delay); - } - finally - { - if (m_executionTimer != null) - m_executionTimer.Start(); - } + if (m_coopSleepHandle == null) + System.Threading.Thread.Sleep(delay); + else + CheckForCoopTermination(delay); } /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 9bb12d3..3406aea 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs @@ -51,7 +51,6 @@ using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; -using System.Diagnostics; namespace OpenSim.Region.ScriptEngine.Shared.Api { @@ -64,8 +63,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal IScriptModuleComms m_comms = null; public void Initialize( - IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle, - Stopwatch executionTimer) + IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) { m_ScriptEngine = scriptEngine; 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 39505e1..92dd813 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -51,7 +51,6 @@ using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; -using System.Diagnostics; namespace OpenSim.Region.ScriptEngine.Shared.Api { @@ -67,8 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal IScriptModuleComms m_comms = null; public void Initialize( - IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle, - Stopwatch executionTimer) + IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) { m_ScriptEngine = scriptEngine; 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 4bb0b74..123f8ca 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -41,7 +41,6 @@ using OpenMetaverse.StructuredData; using Nini.Config; using OpenSim; using OpenSim.Framework; -using System.Diagnostics; using OpenSim.Framework.Console; using OpenSim.Region.Framework.Interfaces; @@ -143,21 +142,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api internal float m_ScriptDistanceFactor = 1.0f; internal Dictionary m_FunctionPerms = new Dictionary(); - /// - /// The timer used by the ScriptInstance to measure how long the script has executed. - /// - private Stopwatch m_executionTimer; - protected IUrlModule m_UrlModule = null; public void Initialize( - IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle, - Stopwatch executionTimer) + IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) { m_ScriptEngine = scriptEngine; m_host = host; m_item = item; - m_executionTimer = executionTimer; m_UrlModule = m_ScriptEngine.World.RequestModuleInterface(); @@ -440,19 +432,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api delay = (int)((float)delay * m_ScriptDelayFactor); if (delay == 0) return; - - if (m_executionTimer != null) - m_executionTimer.Stop(); // sleep time doesn't count as execution time, since it doesn't use the CPU - - try - { - System.Threading.Thread.Sleep(delay); - } - finally - { - if (m_executionTimer != null) - m_executionTimer.Start(); - } + System.Threading.Thread.Sleep(delay); } public LSL_Integer osSetTerrainHeight(int x, int y, double val) -- cgit v1.1