Add number of milliseconds since last update to "show threads"

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2011-11-15 21:49:13 +00:00
parent 6b0553ed7c
commit 66863fdd34
2 changed files with 18 additions and 4 deletions

View File

@ -247,13 +247,17 @@ namespace OpenSim.Framework.Servers
Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreads(); Watchdog.ThreadWatchdogInfo[] threads = Watchdog.GetThreads();
sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine); sb.Append(threads.Length + " threads are being tracked:" + Environment.NewLine);
int timeNow = Util.EnvironmentTickCount();
foreach (Watchdog.ThreadWatchdogInfo twi in threads) foreach (Watchdog.ThreadWatchdogInfo twi in threads)
{ {
Thread t = twi.Thread; Thread t = twi.Thread;
sb.Append( sb.AppendFormat(
"ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", TimeRunning: " "ID: {0}, Name: {1}, Last Update: {2} ms ago, Pri: {3}, State: {4}",
+ "Pri: " + t.Priority + ", State: " + t.ThreadState); t.ManagedThreadId, t.Name, timeNow - twi.LastTick, t.Priority, t.ThreadState);
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);
} }

View File

@ -48,6 +48,15 @@ namespace OpenSim.Framework
public class ThreadWatchdogInfo public class ThreadWatchdogInfo
{ {
public Thread Thread { get; private set; } public Thread Thread { get; private set; }
/// <summary>
/// Approximate tick when this thread was started.
/// </summary>
public int StartTick { get; private set; }
/// <summary>
/// Last time this heartbeat update was invoked
/// </summary>
public int LastTick { get; set; } public int LastTick { get; set; }
/// <summary> /// <summary>
@ -64,7 +73,8 @@ namespace OpenSim.Framework
{ {
Thread = thread; Thread = thread;
Timeout = timeout; Timeout = timeout;
LastTick = Environment.TickCount & Int32.MaxValue; StartTick = Environment.TickCount & Int32.MaxValue;
LastTick = StartTick;
} }
} }