diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 24 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 67 |
2 files changed, 37 insertions, 54 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index f16aefc..549c038 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -74,27 +74,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
74 | private string m_PrimName; | 74 | private string m_PrimName; |
75 | private string m_ScriptName; | 75 | private string m_ScriptName; |
76 | private string m_Assembly; | 76 | private string m_Assembly; |
77 | private int m_StartParam = 0; | 77 | private int m_StartParam; |
78 | private string m_CurrentEvent = String.Empty; | 78 | private string m_CurrentEvent = String.Empty; |
79 | private bool m_InSelfDelete = false; | 79 | private bool m_InSelfDelete; |
80 | private int m_MaxScriptQueue; | 80 | private int m_MaxScriptQueue; |
81 | private bool m_SaveState = true; | 81 | private bool m_SaveState = true; |
82 | private bool m_ShuttingDown = false; | 82 | private bool m_ShuttingDown; |
83 | private int m_ControlEventsInQueue = 0; | 83 | private int m_ControlEventsInQueue; |
84 | private int m_LastControlLevel = 0; | 84 | private int m_LastControlLevel; |
85 | private bool m_CollisionInQueue = false; | 85 | private bool m_CollisionInQueue; |
86 | private TaskInventoryItem m_thisScriptTask; | 86 | private TaskInventoryItem m_thisScriptTask; |
87 | // The following is for setting a minimum delay between events | 87 | // The following is for setting a minimum delay between events |
88 | private double m_minEventDelay = 0; | 88 | private double m_minEventDelay; |
89 | private long m_eventDelayTicks = 0; | 89 | private long m_eventDelayTicks; |
90 | private long m_nextEventTimeTicks = 0; | 90 | private long m_nextEventTimeTicks; |
91 | private bool m_startOnInit = true; | 91 | private bool m_startOnInit = true; |
92 | private UUID m_AttachedAvatar = UUID.Zero; | 92 | private UUID m_AttachedAvatar; |
93 | private StateSource m_stateSource; | 93 | private StateSource m_stateSource; |
94 | private bool m_postOnRez; | 94 | private bool m_postOnRez; |
95 | private bool m_startedFromSavedState = false; | 95 | private bool m_startedFromSavedState; |
96 | private UUID m_CurrentStateHash; | 96 | private UUID m_CurrentStateHash; |
97 | private UUID m_RegionID = UUID.Zero; | 97 | private UUID m_RegionID; |
98 | 98 | ||
99 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | 99 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> |
100 | m_LineMap; | 100 | m_LineMap; |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index b13e0de..b0fce75 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.CodeTools; | |||
50 | using OpenSim.Region.ScriptEngine.Shared.Instance; | 50 | using OpenSim.Region.ScriptEngine.Shared.Instance; |
51 | using OpenSim.Region.ScriptEngine.Interfaces; | 51 | using OpenSim.Region.ScriptEngine.Interfaces; |
52 | 52 | ||
53 | using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>; | ||
54 | using Parallel = OpenSim.Framework.Parallel; | ||
55 | |||
53 | namespace OpenSim.Region.ScriptEngine.XEngine | 56 | namespace OpenSim.Region.ScriptEngine.XEngine |
54 | { | 57 | { |
55 | public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine | 58 | public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine |
@@ -116,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
116 | private Dictionary<UUID, List<UUID> > m_DomainScripts = | 119 | private Dictionary<UUID, List<UUID> > m_DomainScripts = |
117 | new Dictionary<UUID, List<UUID> >(); | 120 | new Dictionary<UUID, List<UUID> >(); |
118 | 121 | ||
119 | private Queue m_CompileQueue = new Queue(100); | 122 | private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); |
120 | IWorkItemResult m_CurrentCompile = null; | 123 | IWorkItemResult m_CurrentCompile = null; |
121 | 124 | ||
122 | public string ScriptEngineName | 125 | public string ScriptEngineName |
@@ -487,16 +490,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
487 | } | 490 | } |
488 | else | 491 | else |
489 | { | 492 | { |
490 | lock (m_CompileQueue) | 493 | m_CompileQueue.Enqueue(parms); |
491 | { | ||
492 | m_CompileQueue.Enqueue(parms); | ||
493 | 494 | ||
494 | if (m_CurrentCompile == null) | 495 | if (m_CurrentCompile == null) |
495 | { | 496 | { |
496 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | 497 | m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null); |
497 | new WorkItemCallback(this.DoOnRezScriptQueue), | ||
498 | new Object[0]); | ||
499 | } | ||
500 | } | 498 | } |
501 | } | 499 | } |
502 | } | 500 | } |
@@ -507,50 +505,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
507 | { | 505 | { |
508 | m_InitialStartup = false; | 506 | m_InitialStartup = false; |
509 | System.Threading.Thread.Sleep(15000); | 507 | System.Threading.Thread.Sleep(15000); |
510 | lock (m_CompileQueue) | 508 | |
509 | if (m_CompileQueue.Count == 0) | ||
511 | { | 510 | { |
512 | if (m_CompileQueue.Count==0) | 511 | // No scripts on region, so won't get triggered later |
513 | // No scripts on region, so won't get triggered later | 512 | // by the queue becoming empty so we trigger it here |
514 | // by the queue becoming empty so we trigger it here | 513 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); |
515 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty); | ||
516 | } | 514 | } |
517 | } | 515 | } |
518 | 516 | ||
519 | Object o; | 517 | List<object[]> compiles = new List<object[]>(); |
520 | lock (m_CompileQueue) | 518 | object[] o; |
519 | while (m_CompileQueue.Dequeue(out o)) | ||
521 | { | 520 | { |
522 | o = m_CompileQueue.Dequeue(); | 521 | compiles.Add(o); |
523 | if (o == null) | ||
524 | { | ||
525 | m_CurrentCompile = null; | ||
526 | return null; | ||
527 | } | ||
528 | } | 522 | } |
529 | 523 | ||
530 | DoOnRezScript(o); | 524 | Parallel.For(0, compiles.Count, delegate(int i) { DoOnRezScript(compiles[i]); }); |
525 | |||
526 | m_CurrentCompile = null; | ||
527 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, | ||
528 | m_ScriptErrorMessage); | ||
529 | m_ScriptFailCount = 0; | ||
531 | 530 | ||
532 | lock (m_CompileQueue) | ||
533 | { | ||
534 | if (m_CompileQueue.Count > 0) | ||
535 | { | ||
536 | m_CurrentCompile = m_ThreadPool.QueueWorkItem( | ||
537 | new WorkItemCallback(this.DoOnRezScriptQueue), | ||
538 | new Object[0]); | ||
539 | } | ||
540 | else | ||
541 | { | ||
542 | m_CurrentCompile = null; | ||
543 | m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount, | ||
544 | m_ScriptErrorMessage); | ||
545 | m_ScriptFailCount = 0; | ||
546 | } | ||
547 | } | ||
548 | return null; | 531 | return null; |
549 | } | 532 | } |
550 | 533 | ||
551 | private bool DoOnRezScript(object parm) | 534 | private bool DoOnRezScript(object[] parms) |
552 | { | 535 | { |
553 | Object[] p = (Object[])parm; | 536 | Object[] p = parms; |
554 | uint localID = (uint)p[0]; | 537 | uint localID = (uint)p[0]; |
555 | UUID itemID = (UUID)p[1]; | 538 | UUID itemID = (UUID)p[1]; |
556 | string script =(string)p[2]; | 539 | string script =(string)p[2]; |