From b08ab1e3754da4a2855bb77fca91dce01e9c2fae Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 3 Sep 2014 23:31:45 +0100
Subject: If BulletSim is running on its own threads, start this thread via the
 thread watchdog.

This allows us to see the presence of the permanent thread via the "show threads" console comand.
Also adds the region name to the thread name.
---
 OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 11 ++++++++---
 prebuild.xml                                    |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index f7317c0..d3b2ad7 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -32,6 +32,7 @@ using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading;
 using OpenSim.Framework;
+using OpenSim.Framework.Monitoring;
 using OpenSim.Region.Framework;
 using OpenSim.Region.CoreModules;
 using Logging = OpenSim.Region.CoreModules.Framework.Statistics.Logging;
@@ -286,9 +287,13 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
         if (BSParam.UseSeparatePhysicsThread)
         {
             // The physics simulation should happen independently of the heartbeat loop
-            m_physicsThread = new Thread(BulletSPluginPhysicsThread);
-            m_physicsThread.Name = BulletEngineName;
-            m_physicsThread.Start();
+                m_physicsThread 
+                    = Watchdog.StartThread(
+                        BulletSPluginPhysicsThread, 
+                        string.Format("{0} ({1})", BulletEngineName, RegionName), 
+                        ThreadPriority.Normal, 
+                        true, 
+                        false);
         }
     }
 
diff --git a/prebuild.xml b/prebuild.xml
index 006f545..ba18a2c 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1746,6 +1746,7 @@
       <Reference name="OpenMetaverseTypes" path="../../../../bin/"/>
       <Reference name="Nini.dll"  path="../../../../bin/"/>
       <Reference name="OpenSim.Framework"/>
+      <Reference name="OpenSim.Framework.Monitoring"/>
       <Reference name="OpenSim.Region.Framework"/>
       <Reference name="OpenSim.Region.CoreModules"/>
       <Reference name="OpenSim.Region.OptionalModules"/>
-- 
cgit v1.1