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 a568f06b7f.
This commit is contained in:
Melanie Thielker
2015-08-17 18:11:45 +02:00
parent 1de5612d8b
commit ee7debcca6
18 changed files with 49 additions and 95 deletions

View File

@@ -103,11 +103,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// <remarks>null if co-operative script termination is not active</remarks>
WaitHandle m_coopSleepHandle;
/// <summary>
/// The timer used by the ScriptInstance to measure how long the script has executed.
/// </summary>
private Stopwatch m_executionTimer;
/// <summary>
/// The item that hosts this script
/// </summary>
@@ -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);
}
/// <summary>

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
/// <summary>
/// The timer used by the ScriptInstance to measure how long the script has executed.
/// </summary>
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<IUrlModule>();
@@ -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)