aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/XEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs67
1 files changed, 25 insertions, 42 deletions
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;
50using OpenSim.Region.ScriptEngine.Shared.Instance; 50using OpenSim.Region.ScriptEngine.Shared.Instance;
51using OpenSim.Region.ScriptEngine.Interfaces; 51using OpenSim.Region.ScriptEngine.Interfaces;
52 52
53using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>;
54using Parallel = OpenSim.Framework.Parallel;
55
53namespace OpenSim.Region.ScriptEngine.XEngine 56namespace 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];