From 7db38a351c19341e7332dc95cdab5db84ef48226 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 15 Nov 2011 21:49:13 +0000
Subject: Add number of milliseconds since last update to "show threads"
---
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 10 +++++++---
OpenSim/Framework/Watchdog.cs | 12 +++++++++++-
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 3d20080..65d4d32 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -247,13 +247,17 @@ namespace OpenSim.Framework.Servers
Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreads();
sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
+
+ int timeNow = Util.EnvironmentTickCount();
+
foreach (Watchdog.ThreadWatchdogInfo twi in threads)
{
Thread t = twi.Thread;
- sb.Append(
- "ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", TimeRunning: "
- + "Pri: " + t.Priority + ", State: " + t.ThreadState);
+ sb.AppendFormat(
+ "ID: {0}, Name: {1}, Last Update: {2} ms ago, Pri: {3}, State: {4}",
+ t.ManagedThreadId, t.Name, timeNow - twi.LastTick, t.Priority, t.ThreadState);
+
sb.Append(Environment.NewLine);
}
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs
index 8e82f5a..0ee0c5b 100644
--- a/OpenSim/Framework/Watchdog.cs
+++ b/OpenSim/Framework/Watchdog.cs
@@ -48,6 +48,15 @@ namespace OpenSim.Framework
public class ThreadWatchdogInfo
{
public Thread Thread { get; private set; }
+
+ ///
+ /// Approximate tick when this thread was started.
+ ///
+ public int StartTick { get; private set; }
+
+ ///
+ /// Last time this heartbeat update was invoked
+ ///
public int LastTick { get; set; }
///
@@ -64,7 +73,8 @@ namespace OpenSim.Framework
{
Thread = thread;
Timeout = timeout;
- LastTick = Environment.TickCount & Int32.MaxValue;
+ StartTick = Environment.TickCount & Int32.MaxValue;
+ LastTick = StartTick;
}
}
--
cgit v1.1