Implement co-operative script termination if termination comes during a script wait event (llSleep(), etc.)

This makes use of EventWaitHandles since various web references indicate that Thread.Interrupt() can also cause runtime instability.
If co-op termination is enabled, then termination sets the wait handle instead of waiting for a timeout before possibly aborting the thread.
This allows the script to cleanly terminate if it's in a llSleep/LL function delay or the next time it enters such a wait without any timeout period.
Co-op termination is not yet testable since checking for termination request within loops that never trigger a wait is not yet implemented.
This commit, unlike 1b5c41c, passes the wait handle as an extra parameter through IScript.Initialize() instead of passing IScriptInstance itself.
This commit is contained in:
Justin Clark-Casey (justincc)
2013-01-16 02:07:43 +00:00
parent b8949024bc
commit 0963ece25b
19 changed files with 331 additions and 55 deletions

View File

@@ -26,6 +26,7 @@
*/
using System;
using System.Threading;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
@@ -40,7 +41,11 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
/// </summary>
/// <remarks>
/// Each API has an identifier, which is used to load the proper runtime assembly at load time.
/// <param name='scriptInstance'>/param>
void Initialize(IScriptInstance scriptInstance);
/// <param name='scriptEngine'>/param>
/// <param name='host'>/param>
/// <param name='item'>/param>
/// <param name='coopSleepHandle'>/param>
void Initialize(
IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, EventWaitHandle coopSleepHandle);
}
}