From af286d5fcb688e8b64202b6deca4f249e9a2b6b8 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 17 Sep 2014 17:56:10 -0400 Subject: Small changes to threading to send thread names to unmanaged threads. Needs Mono 3.6+ to see thread names in utilities like top -H . Some formatting of the thread name to fin in the 16 byte limit on Linux. Please test on Windows to see if the work has any adverse effects. --- OpenSim/Framework/Monitoring/Watchdog.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim/Framework/Monitoring/Watchdog.cs') diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index e9e7bd2..e9f22f1 100644 --- a/OpenSim/Framework/Monitoring/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs @@ -87,7 +87,7 @@ namespace OpenSim.Framework.Monitoring /// public Stat Stat { get; set; } - public ThreadWatchdogInfo(Thread thread, int timeout) + public ThreadWatchdogInfo(Thread thread, int timeout, string name) { Thread = thread; Timeout = timeout; @@ -96,8 +96,8 @@ namespace OpenSim.Framework.Monitoring Stat = new Stat( - thread.Name, - string.Format("Last update of thread {0}", thread.Name), + name, + string.Format("Last update of thread {0}", name), "", "ms", "server", @@ -216,12 +216,11 @@ namespace OpenSim.Framework.Monitoring bool alarmIfTimeout, Func alarmMethod, int timeout, bool log = true) { Thread thread = new Thread(start); - thread.Name = name; thread.Priority = priority; thread.IsBackground = isBackground; ThreadWatchdogInfo twi - = new ThreadWatchdogInfo(thread, timeout) + = new ThreadWatchdogInfo(thread, timeout, name) { AlarmIfTimeout = alarmIfTimeout, AlarmMethod = alarmMethod }; if (log) @@ -230,8 +229,10 @@ namespace OpenSim.Framework.Monitoring lock (m_threads) m_threads.Add(twi.Thread.ManagedThreadId, twi); - + thread.Start(); + thread.Name = name; + return thread; } -- cgit v1.1