aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Monitoring/Watchdog.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-11-21 01:08:58 +0000
committerJustin Clark-Casey (justincc)2014-11-25 23:23:11 +0000
commit28d1dbfee4256a97744ed1cebe21971adf5fdaef (patch)
treec7268d275db86f783e35a9e77415760bd9142561 /OpenSim/Framework/Monitoring/Watchdog.cs
parentAdd [BulletSim] option AvatarToAvatarCollisionsByDefault to control whether a... (diff)
downloadopensim-SC_OLD-28d1dbfee4256a97744ed1cebe21971adf5fdaef.zip
opensim-SC_OLD-28d1dbfee4256a97744ed1cebe21971adf5fdaef.tar.gz
opensim-SC_OLD-28d1dbfee4256a97744ed1cebe21971adf5fdaef.tar.bz2
opensim-SC_OLD-28d1dbfee4256a97744ed1cebe21971adf5fdaef.tar.xz
Move conditionals which control whether a task is placed in the JobEngine inside Watchdog.RunJob() (renamed from RunWhenPossible) and generalize them.
Diffstat (limited to 'OpenSim/Framework/Monitoring/Watchdog.cs')
-rw-r--r--OpenSim/Framework/Monitoring/Watchdog.cs39
1 files changed, 37 insertions, 2 deletions
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index ebbf095..0feec7c 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -454,7 +454,38 @@ namespace OpenSim.Framework.Monitoring
454 m_watchdogTimer.Start(); 454 m_watchdogTimer.Start();
455 } 455 }
456 456
457 public static void RunWhenPossible(string jobType, WaitCallback callback, string name, object obj, bool log = false) 457 /// <summary>
458 /// Run a job.
459 /// </summary>
460 /// <remarks>
461 /// This differs from direct scheduling (e.g. Util.FireAndForget) in that a job can be run in the job
462 /// engine if it is running, where all jobs are currently performed in sequence on a single thread. This is
463 /// to prevent observed overload and server freeze problems when there are hundreds of connections which all attempt to
464 /// perform work at once (e.g. in conference situations). With lower numbers of connections, the small
465 /// delay in performing jobs in sequence rather than concurrently has not been notiecable in testing, though a future more
466 /// sophisticated implementation could perform jobs concurrently when the server is under low load.
467 ///
468 /// However, be advised that some callers of this function rely on all jobs being performed in sequence if any
469 /// jobs are performed in sequence (i.e. if jobengine is active or not). Therefore, expanding the jobengine
470 /// beyond a single thread will require considerable thought.
471 ///
472 /// Also, any jobs submitted must be guaranteed to complete within a reasonable timeframe (e.g. they cannot
473 /// incorporate a network delay with a long timeout). At the moment, work that could suffer such issues
474 /// should still be run directly with RunInThread(), Util.FireAndForget(), etc. This is another area where
475 /// the job engine could be improved and so CPU utilization improved by better management of concurrency within
476 /// OpenSimulator.
477 /// </remarks>
478 /// <param name="jobType">General classification for the job (e.g. "RezAttachments").</param>
479 /// <param name="callback">Callback for job.</param>
480 /// <param name="name">Specific name of job (e.g. "RezAttachments for Joe Bloggs"</param>
481 /// <param name="obj">Object to pass to callback when run</param>
482 /// <param name="canRunInThisThread">If set to true then the job may be run in ths calling thread.</param>
483 /// <param name="mustNotTimeout">If the true then the job must never timeout.</param>
484 /// <param name="log">If set to true then extra logging is performed.</param>
485 public static void RunJob(
486 string jobType, WaitCallback callback, string name, object obj,
487 bool canRunInThisThread = false, bool mustNotTimeout = false,
488 bool log = false)
458 { 489 {
459 if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest) 490 if (Util.FireAndForgetMethod == FireAndForgetMethod.RegressionTest)
460 { 491 {
@@ -465,8 +496,12 @@ namespace OpenSim.Framework.Monitoring
465 496
466 if (JobEngine.IsRunning) 497 if (JobEngine.IsRunning)
467 JobEngine.QueueRequest(name, callback, obj); 498 JobEngine.QueueRequest(name, callback, obj);
468 else 499 else if (canRunInThisThread)
500 callback(obj);
501 else if (mustNotTimeout)
469 RunInThread(callback, name, obj, log); 502 RunInThread(callback, name, obj, log);
503 else
504 Util.FireAndForget(callback, obj, name);
470 } 505 }
471 } 506 }
472} \ No newline at end of file 507} \ No newline at end of file