aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Monitoring/WorkManager.cs
diff options
context:
space:
mode:
authorUbitUmarov2018-12-28 13:52:59 +0000
committerUbitUmarov2018-12-28 13:52:59 +0000
commit4a73cc81dc4e03b2b7c46829cecfc0627c3fddb4 (patch)
tree6e8200b3b7a3c0465853e42bbd790a59ccd4e312 /OpenSim/Framework/Monitoring/WorkManager.cs
parentupdate pbs (diff)
downloadopensim-SC-4a73cc81dc4e03b2b7c46829cecfc0627c3fddb4.zip
opensim-SC-4a73cc81dc4e03b2b7c46829cecfc0627c3fddb4.tar.gz
opensim-SC-4a73cc81dc4e03b2b7c46829cecfc0627c3fddb4.tar.bz2
opensim-SC-4a73cc81dc4e03b2b7c46829cecfc0627c3fddb4.tar.xz
now break several things at same time... sog/sop updates, threads options,...
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Monitoring/WorkManager.cs68
1 files changed, 16 insertions, 52 deletions
diff --git a/OpenSim/Framework/Monitoring/WorkManager.cs b/OpenSim/Framework/Monitoring/WorkManager.cs
index 5d9b185..c6d97e1 100644
--- a/OpenSim/Framework/Monitoring/WorkManager.cs
+++ b/OpenSim/Framework/Monitoring/WorkManager.cs
@@ -88,6 +88,11 @@ namespace OpenSim.Framework.Monitoring
88 Watchdog.Stop(); 88 Watchdog.Stop();
89 } 89 }
90 90
91 public static Thread StartThread(ThreadStart start, string name, bool alarmIfTimeout = false, bool log = true)
92 {
93 return StartThread(start, name, ThreadPriority.Normal, true, alarmIfTimeout, null, Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS, log);
94 }
95
91 /// <summary> 96 /// <summary>
92 /// Start a new long-lived thread. 97 /// Start a new long-lived thread.
93 /// </summary> 98 /// </summary>
@@ -99,9 +104,9 @@ namespace OpenSim.Framework.Monitoring
99 /// <param name="log">If true then creation of thread is logged.</param> 104 /// <param name="log">If true then creation of thread is logged.</param>
100 /// <returns>The newly created Thread object</returns> 105 /// <returns>The newly created Thread object</returns>
101 public static Thread StartThread( 106 public static Thread StartThread(
102 ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout, bool log = true) 107 ThreadStart start, string name, ThreadPriority priority, bool alarmIfTimeout, bool log = true)
103 { 108 {
104 return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS, log); 109 return StartThread(start, name, priority, true, alarmIfTimeout, null, Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS, log);
105 } 110 }
106 111
107 /// <summary> 112 /// <summary>
@@ -162,15 +167,22 @@ namespace OpenSim.Framework.Monitoring
162 { 167 {
163 Culture.SetCurrentCulture(); 168 Culture.SetCurrentCulture();
164 callback(obj); 169 callback(obj);
165 Watchdog.RemoveThread(log:false);
166 } 170 }
167 catch (Exception e) 171 catch (Exception e)
168 { 172 {
169 m_log.Error(string.Format("[WATCHDOG]: Exception in thread {0}.", name), e); 173 m_log.Error(string.Format("[WATCHDOG]: Exception in thread {0}.", name), e);
170 } 174 }
175 finally
176 {
177 try
178 {
179 Watchdog.RemoveThread(log: false);
180 }
181 catch { }
182 }
171 }); 183 });
172 184
173 StartThread(ts, name, ThreadPriority.Normal, true, false, log:log); 185 StartThread(ts, name, false, log:log);
174 } 186 }
175 187
176 /// <summary> 188 /// <summary>
@@ -187,54 +199,6 @@ namespace OpenSim.Framework.Monitoring
187 Util.FireAndForget(callback, obj, name, timeout); 199 Util.FireAndForget(callback, obj, name, timeout);
188 } 200 }
189 201
190 /// <summary>
191 /// Run a job.
192 /// </summary>
193 /// <remarks>
194 /// This differs from direct scheduling (e.g. Util.FireAndForget) in that a job can be run in the job
195 /// engine if it is running, where all jobs are currently performed in sequence on a single thread. This is
196 /// to prevent observed overload and server freeze problems when there are hundreds of connections which all attempt to
197 /// perform work at once (e.g. in conference situations). With lower numbers of connections, the small
198 /// delay in performing jobs in sequence rather than concurrently has not been notiecable in testing, though a future more
199 /// sophisticated implementation could perform jobs concurrently when the server is under low load.
200 ///
201 /// However, be advised that some callers of this function rely on all jobs being performed in sequence if any
202 /// jobs are performed in sequence (i.e. if jobengine is active or not). Therefore, expanding the jobengine
203 /// beyond a single thread will require considerable thought.
204 ///
205 /// Also, any jobs submitted must be guaranteed to complete within a reasonable timeframe (e.g. they cannot
206 /// incorporate a network delay with a long timeout). At the moment, work that could suffer such issues
207 /// should still be run directly with RunInThread(), Util.FireAndForget(), etc. This is another area where
208 /// the job engine could be improved and so CPU utilization improved by better management of concurrency within
209 /// OpenSimulator.
210 /// </remarks>
211 /// <param name="jobType">General classification for the job (e.g. "RezAttachments").</param>
212 /// <param name="callback">Callback for job.</param>
213 /// <param name="obj">Object to pass to callback when run</param>
214 /// <param name="name">Specific name of job (e.g. "RezAttachments for Joe Bloggs"</param>
215 /// <param name="canRunInThisThread">If set to true then the job may be run in ths calling thread.</param>
216 /// <param name="mustNotTimeout">If the true then the job must never timeout.</param>
217 /// <param name="log">If set to true then extra logging is performed.</param>
218 public static void RunJob(
219 string jobType, WaitCallback callback, object obj, string name,
220 bool canRunInThisThread = false, bool mustNotTimeout = false,
221 bool log = false)
222 {
223 if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
224 {
225 Culture.SetCurrentCulture();
226 callback(obj);
227 return;
228 }
229
230 if (JobEngine.IsRunning)
231 JobEngine.QueueJob(name, () => callback(obj));
232 else if (canRunInThisThread)
233 callback(obj);
234 else
235 Util.FireAndForget(callback, obj, name, !mustNotTimeout);
236 }
237
238 private static void HandleControlCommand(string module, string[] args) 202 private static void HandleControlCommand(string module, string[] args)
239 { 203 {
240 // if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene) 204 // if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_udpServer.Scene)