aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs65
5 files changed, 79 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
index 7c22eed..6b3804c 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
57 bool GetScriptState(LLUUID itemID); 57 bool GetScriptState(LLUUID itemID);
58 void SetState(LLUUID itemID, string newState); 58 void SetState(LLUUID itemID, string newState);
59 int GetStartParameter(LLUUID itemID); 59 int GetStartParameter(LLUUID itemID);
60 IWorkItemResult QueueEventHandler(object parms); 60 IScriptWorkItem QueueEventHandler(object parms);
61 61
62 DetectParams GetDetectParams(LLUUID item, int number); 62 DetectParams GetDetectParams(LLUUID item, int number);
63 } 63 }
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index 03a3802..3aeb602 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -43,6 +43,13 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
43 AttachmentCrossing = 2 43 AttachmentCrossing = 2
44 } 44 }
45 45
46 public interface IScriptWorkItem
47 {
48 bool Cancel();
49 void Abort();
50 bool Wait(TimeSpan t);
51 }
52
46 public interface IScriptInstance 53 public interface IScriptInstance
47 { 54 {
48 bool Running { get; set; } 55 bool Running { get; set; }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index ff50396..8ce1413 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
53 public class ScriptInstance : IScriptInstance 53 public class ScriptInstance : IScriptInstance
54 { 54 {
55 private IScriptEngine m_Engine; 55 private IScriptEngine m_Engine;
56 private IWorkItemResult m_CurrentResult=null; 56 private IScriptWorkItem m_CurrentResult=null;
57 private Queue m_EventQueue = new Queue(32); 57 private Queue m_EventQueue = new Queue(32);
58 private bool m_RunEvents = false; 58 private bool m_RunEvents = false;
59 private LLUUID m_ItemID; 59 private LLUUID m_ItemID;
@@ -346,7 +346,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
346 346
347 public bool Stop(int timeout) 347 public bool Stop(int timeout)
348 { 348 {
349 IWorkItemResult result; 349 IScriptWorkItem result;
350 350
351 lock (m_EventQueue) 351 lock (m_EventQueue)
352 { 352 {
@@ -370,7 +370,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
370 m_RunEvents = false; 370 m_RunEvents = false;
371 } 371 }
372 372
373 if (SmartThreadPool.WaitAll(new IWorkItemResult[] {result}, new TimeSpan((long)timeout * 100000), false)) 373 if (result.Wait(new TimeSpan((long)timeout * 100000)))
374 { 374 {
375 return true; 375 return true;
376 } 376 }
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 8fd8a1c..a33554c 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -655,10 +655,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
655 // 655 //
656 // Used by script instances to queue event handler jobs 656 // Used by script instances to queue event handler jobs
657 // 657 //
658 public IWorkItemResult QueueEventHandler(object parms) 658 public IScriptWorkItem QueueEventHandler(object parms)
659 { 659 {
660 return m_ThreadPool.QueueWorkItem(new WorkItemCallback( 660 return new XWorkItem(m_ThreadPool.QueueWorkItem(new WorkItemCallback(
661 this.ProcessEventHandler), parms); 661 this.ProcessEventHandler), parms));
662 } 662 }
663 663
664 // 664 //
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs b/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs
new file mode 100644
index 0000000..4686d82
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/XEngine/XWorkItem.cs
@@ -0,0 +1,65 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Threading;
31using Amib.Threading;
32using OpenSim.Region.ScriptEngine.Interfaces;
33
34namespace OpenSim.Region.ScriptEngine.XEngine
35{
36 public class XWorkItem : IScriptWorkItem
37 {
38 private IWorkItemResult wr;
39
40 public IWorkItemResult WorkItem
41 {
42 get { return wr; }
43 }
44
45 public XWorkItem(IWorkItemResult w)
46 {
47 wr = w;
48 }
49
50 public bool Cancel()
51 {
52 return wr.Cancel();
53 }
54
55 public void Abort()
56 {
57 wr.Abort();
58 }
59
60 public bool Wait(TimeSpan t)
61 {
62 return SmartThreadPool.WaitAll(new IWorkItemResult[] {wr}, t, false);
63 }
64 }
65}