diff options
author | Melanie Thielker | 2008-09-21 02:52:12 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-09-21 02:52:12 +0000 |
commit | 85586bb7b20b09e02e4b19c47a87ed8dd480a62a (patch) | |
tree | dec0df055451fd2f2f1d823795b52d09cd4ccb4b /OpenSim/Region/ScriptEngine | |
parent | Update svn properties, minor formatting cleanup. (diff) | |
download | opensim-SC_OLD-85586bb7b20b09e02e4b19c47a87ed8dd480a62a.zip opensim-SC_OLD-85586bb7b20b09e02e4b19c47a87ed8dd480a62a.tar.gz opensim-SC_OLD-85586bb7b20b09e02e4b19c47a87ed8dd480a62a.tar.bz2 opensim-SC_OLD-85586bb7b20b09e02e4b19c47a87ed8dd480a62a.tar.xz |
Change XEngine startup to enable it to run as a normal region module
rather than a special one
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 67 |
1 files changed, 40 insertions, 27 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index caaaf34..d6e6dae 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -60,6 +60,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
60 | private Scene m_Scene; | 60 | private Scene m_Scene; |
61 | private IConfig m_ScriptConfig; | 61 | private IConfig m_ScriptConfig; |
62 | private Compiler m_Compiler; | 62 | private Compiler m_Compiler; |
63 | private int m_MinThreads; | ||
64 | private int m_MaxThreads ; | ||
65 | private int m_IdleTimeout; | ||
66 | private int m_StackSize; | ||
67 | private int m_SleepTime; | ||
68 | private int m_SaveTime; | ||
69 | private ThreadPriority m_Prio; | ||
63 | 70 | ||
64 | // disable warning: need to keep a reference to XEngine.EventManager | 71 | // disable warning: need to keep a reference to XEngine.EventManager |
65 | // alive to avoid it being garbage collected | 72 | // alive to avoid it being garbage collected |
@@ -159,34 +166,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
159 | return; | 166 | return; |
160 | } | 167 | } |
161 | 168 | ||
162 | int minThreads = m_ScriptConfig.GetInt("MinThreads", 2); | 169 | m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2); |
163 | int maxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); | 170 | m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); |
164 | int idleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); | 171 | m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); |
165 | string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); | 172 | string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); |
166 | int maxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); | 173 | m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); |
167 | int stackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); | 174 | m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); |
168 | int sleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; | 175 | m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; |
176 | |||
169 | m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); | 177 | m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30); |
170 | m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); | 178 | m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false); |
171 | int saveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000; | 179 | m_SaveTime = m_ScriptConfig.GetInt("SaveInterval", 120) * 1000; |
172 | 180 | ||
173 | ThreadPriority prio = ThreadPriority.BelowNormal; | 181 | m_Prio = ThreadPriority.BelowNormal; |
174 | switch (priority) | 182 | switch (priority) |
175 | { | 183 | { |
176 | case "Lowest": | 184 | case "Lowest": |
177 | prio = ThreadPriority.Lowest; | 185 | m_Prio = ThreadPriority.Lowest; |
178 | break; | 186 | break; |
179 | case "BelowNormal": | 187 | case "BelowNormal": |
180 | prio = ThreadPriority.BelowNormal; | 188 | m_Prio = ThreadPriority.BelowNormal; |
181 | break; | 189 | break; |
182 | case "Normal": | 190 | case "Normal": |
183 | prio = ThreadPriority.Normal; | 191 | m_Prio = ThreadPriority.Normal; |
184 | break; | 192 | break; |
185 | case "AboveNormal": | 193 | case "AboveNormal": |
186 | prio = ThreadPriority.AboveNormal; | 194 | m_Prio = ThreadPriority.AboveNormal; |
187 | break; | 195 | break; |
188 | case "Highest": | 196 | case "Highest": |
189 | prio = ThreadPriority.Highest; | 197 | m_Prio = ThreadPriority.Highest; |
190 | break; | 198 | break; |
191 | default: | 199 | default: |
192 | m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority); | 200 | m_log.ErrorFormat("[XEngine] Invalid thread priority: '{0}'. Assuming BelowNormal", priority); |
@@ -198,14 +206,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
198 | m_ScriptEngines.Add(this); | 206 | m_ScriptEngines.Add(this); |
199 | } | 207 | } |
200 | 208 | ||
201 | m_EventManager = new EventManager(this); | 209 | scene.RegisterModuleInterface<IScriptModule>(this); |
210 | |||
211 | // Needs to be here so we can queue the scripts that need starting | ||
212 | // | ||
213 | m_Scene.EventManager.OnRezScript += OnRezScript; | ||
202 | 214 | ||
203 | StartEngine(minThreads, maxThreads, idleTimeout, prio, | 215 | // Complete basic setup of the thread pool |
204 | maxScriptQueue, stackSize); | 216 | // |
217 | SetupEngine(m_MinThreads, m_MaxThreads, m_IdleTimeout, m_Prio, | ||
218 | m_MaxScriptQueue, m_StackSize); | ||
219 | } | ||
220 | |||
221 | public void PostInitialise() | ||
222 | { | ||
223 | m_EventManager = new EventManager(this); | ||
205 | 224 | ||
206 | m_Compiler = new Compiler(this); | 225 | m_Compiler = new Compiler(this); |
207 | 226 | ||
208 | m_Scene.EventManager.OnRezScript += OnRezScript; | ||
209 | m_Scene.EventManager.OnRemoveScript += OnRemoveScript; | 227 | m_Scene.EventManager.OnRemoveScript += OnRemoveScript; |
210 | m_Scene.EventManager.OnScriptReset += OnScriptReset; | 228 | m_Scene.EventManager.OnScriptReset += OnScriptReset; |
211 | m_Scene.EventManager.OnStartScript += OnStartScript; | 229 | m_Scene.EventManager.OnStartScript += OnStartScript; |
@@ -214,23 +232,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
214 | 232 | ||
215 | m_AsyncCommands = new AsyncCommandManager(this); | 233 | m_AsyncCommands = new AsyncCommandManager(this); |
216 | 234 | ||
217 | if (sleepTime > 0) | 235 | if (m_SleepTime > 0) |
218 | { | 236 | { |
219 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), | 237 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), |
220 | new Object[]{ sleepTime }); | 238 | new Object[]{ m_SleepTime }); |
221 | } | 239 | } |
222 | 240 | ||
223 | if (saveTime > 0) | 241 | if (m_SaveTime > 0) |
224 | { | 242 | { |
225 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup), | 243 | m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoBackup), |
226 | new Object[] { saveTime }); | 244 | new Object[] { m_SaveTime }); |
227 | } | 245 | } |
228 | 246 | ||
229 | scene.RegisterModuleInterface<IScriptModule>(this); | ||
230 | } | ||
231 | |||
232 | public void PostInitialise() | ||
233 | { | ||
234 | m_ThreadPool.Start(); | 247 | m_ThreadPool.Start(); |
235 | } | 248 | } |
236 | 249 | ||
@@ -641,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
641 | // | 654 | // |
642 | // Start processing | 655 | // Start processing |
643 | // | 656 | // |
644 | private void StartEngine(int minThreads, int maxThreads, | 657 | private void SetupEngine(int minThreads, int maxThreads, |
645 | int idleTimeout, ThreadPriority threadPriority, | 658 | int idleTimeout, ThreadPriority threadPriority, |
646 | int maxScriptQueue, int stackSize) | 659 | int maxScriptQueue, int stackSize) |
647 | { | 660 | { |