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.cs35
1 files changed, 27 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 44072c6..d47fd6b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -83,10 +83,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
83 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi 83 public class LSL_Api : MarshalByRefObject, ILSL_Api, IScriptApi
84 { 84 {
85 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 85 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
86
86 protected IScriptEngine m_ScriptEngine; 87 protected IScriptEngine m_ScriptEngine;
87 protected SceneObjectPart m_host; 88 protected SceneObjectPart m_host;
88 89
89 /// <summary> 90 /// <summary>
91 /// Used for script sleeps when we are using co-operative script termination.
92 /// </summary>
93 /// <remarks>null if co-operative script termination is not active</remarks>
94 EventWaitHandle m_coopSleepHandle;
95
96 /// <summary>
90 /// The item that hosts this script 97 /// The item that hosts this script
91 /// </summary> 98 /// </summary>
92 protected TaskInventoryItem m_item; 99 protected TaskInventoryItem m_item;
@@ -110,13 +117,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
110 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. 117 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
111 protected ISoundModule m_SoundModule = null; 118 protected ISoundModule m_SoundModule = null;
112 119
113 public void Initialize(IScriptInstance scriptInstance) 120 public void Initialize(
121 IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle)
114 { 122 {
115 m_ScriptEngine = scriptInstance.Engine; 123 m_ScriptEngine = scriptEngine;
116 m_host = scriptInstance.Part; 124 m_host = host;
117 m_item = scriptInstance.ScriptTask; 125 m_item = item;
126 m_coopSleepHandle = coopSleepHandle;
118 127
119 LoadLimits(); // read script limits from config. 128 LoadConfig();
120 129
121 m_TransferModule = 130 m_TransferModule =
122 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); 131 m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
@@ -129,7 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
129 /// <summary> 138 /// <summary>
130 /// Load configuration items that affect script, object and run-time behavior. */ 139 /// Load configuration items that affect script, object and run-time behavior. */
131 /// </summary> 140 /// </summary>
132 private void LoadLimits() 141 private void LoadConfig()
133 { 142 {
134 m_ScriptDelayFactor = 143 m_ScriptDelayFactor =
135 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f); 144 m_ScriptEngine.Config.GetFloat("ScriptDelayFactor", 1.0f);
@@ -175,7 +184,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
175 delay = (int)((float)delay * m_ScriptDelayFactor); 184 delay = (int)((float)delay * m_ScriptDelayFactor);
176 if (delay == 0) 185 if (delay == 0)
177 return; 186 return;
178 System.Threading.Thread.Sleep(delay); 187
188 Sleep(delay);
189 }
190
191 protected virtual void Sleep(int delay)
192 {
193 if (m_coopSleepHandle == null)
194 System.Threading.Thread.Sleep(delay);
195 else if (m_coopSleepHandle.WaitOne(delay))
196 throw new ScriptCoopStopException();
179 } 197 }
180 198
181 public Scene World 199 public Scene World
@@ -2914,7 +2932,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2914 { 2932 {
2915// m_log.Info("llSleep snoozing " + sec + "s."); 2933// m_log.Info("llSleep snoozing " + sec + "s.");
2916 m_host.AddScriptLPS(1); 2934 m_host.AddScriptLPS(1);
2917 Thread.Sleep((int)(sec * 1000)); 2935
2936 Sleep((int)(sec * 1000));
2918 } 2937 }
2919 2938
2920 public LSL_Float llGetMass() 2939 public LSL_Float llGetMass()