From 4a475ca2be259cf3e31b29148f04f325b304a6c5 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 25 Aug 2008 23:21:07 +0000
Subject: * minor: refactor thread report into a method that returns a string
rather than displays information directly
---
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 44 +++++++++++++++++---------
1 file changed, 29 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 29ee143..ea3eed1 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -110,6 +110,32 @@ namespace OpenSim.Framework.Servers
m_log.Debug(sb);
}
+
+ ///
+ /// Get a report about the registered threads in this server.
+ ///
+ protected string GetThreadReport()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ List threads = ThreadTracker.GetThreads();
+ if (threads == null)
+ {
+ sb.Append("Thread tracking is only enabled in DEBUG mode.");
+ }
+ else
+ {
+ sb.Append(threads.Count + " threads are being tracked:" + Environment.NewLine);
+ foreach (Thread t in threads)
+ {
+ sb.Append(
+ "ID: " + t.ManagedThreadId + ", Name: " + t.Name + ", Alive: " + t.IsAlive
+ + ", Pri: " + t.Priority + ", State: " + t.ThreadState + Environment.NewLine);
+ }
+ }
+
+ return sb.ToString();
+ }
///
/// Return a report about the uptime of this server
@@ -261,7 +287,7 @@ namespace OpenSim.Framework.Servers
/// Show help information
///
///
- public virtual void ShowHelp(string[] helpArgs)
+ protected virtual void ShowHelp(string[] helpArgs)
{
if (helpArgs.Length == 0)
{
@@ -283,7 +309,7 @@ namespace OpenSim.Framework.Servers
return;
}
- }
+ }
///
/// Outputs to the console information about the region
@@ -308,19 +334,7 @@ namespace OpenSim.Framework.Servers
break;
case "threads":
- List threads = ThreadTracker.GetThreads();
- if (threads == null)
- {
- Notice("Thread tracking is only enabled in DEBUG mode.");
- }
- else
- {
- Notice(threads.Count + " threads are being tracked:");
- foreach (Thread t in threads)
- {
- Notice("ID: " + t.ManagedThreadId.ToString() + ", Name: " + t.Name + ", Alive: " + t.IsAlive.ToString() + ", Pri: " + t.Priority.ToString() + ", State: " + t.ThreadState.ToString());
- }
- }
+ Notice(GetThreadReport());
break;
case "uptime":
--
cgit v1.1