aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/ThreadTracker.cs
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2009-08-13 22:12:37 -0400
committerTeravus Ovares (Dan Olivares)2009-08-13 22:12:37 -0400
commit0781ac9a5e307e6ed0a0685c1dad98d5fb51b76b (patch)
tree8e1a3d42e2dfe0f9c7bd4f55b6983daae5c4dc59 /OpenSim/Framework/ThreadTracker.cs
parent* Add AgentCircuitManager tests for adding, removing, changing circuit code, ... (diff)
downloadopensim-SC_OLD-0781ac9a5e307e6ed0a0685c1dad98d5fb51b76b.zip
opensim-SC_OLD-0781ac9a5e307e6ed0a0685c1dad98d5fb51b76b.tar.gz
opensim-SC_OLD-0781ac9a5e307e6ed0a0685c1dad98d5fb51b76b.tar.bz2
opensim-SC_OLD-0781ac9a5e307e6ed0a0685c1dad98d5fb51b76b.tar.xz
* Add ThreadTracker Tests, Tests default thread, Adding Testing and Removing a thread, a dead thread, and a null Thread
* Fix a null thread situation
Diffstat (limited to 'OpenSim/Framework/ThreadTracker.cs')
-rw-r--r--OpenSim/Framework/ThreadTracker.cs36
1 files changed, 24 insertions, 12 deletions
diff --git a/OpenSim/Framework/ThreadTracker.cs b/OpenSim/Framework/ThreadTracker.cs
index d8bd2c0..fa6f0b8 100644
--- a/OpenSim/Framework/ThreadTracker.cs
+++ b/OpenSim/Framework/ThreadTracker.cs
@@ -77,12 +77,15 @@ namespace OpenSim.Framework
77 public static void Add(Thread thread) 77 public static void Add(Thread thread)
78 { 78 {
79#if DEBUG 79#if DEBUG
80 lock (m_Threads) 80 if (thread != null)
81 { 81 {
82 ThreadTrackerItem tti = new ThreadTrackerItem(); 82 lock (m_Threads)
83 tti.Thread = thread; 83 {
84 tti.LastSeenActive = DateTime.Now.Ticks; 84 ThreadTrackerItem tti = new ThreadTrackerItem();
85 m_Threads.Add(tti); 85 tti.Thread = thread;
86 tti.LastSeenActive = DateTime.Now.Ticks;
87 m_Threads.Add(tti);
88 }
86 } 89 }
87#endif 90#endif
88 } 91 }
@@ -107,16 +110,25 @@ namespace OpenSim.Framework
107 { 110 {
108 foreach (ThreadTrackerItem tti in new ArrayList(m_Threads)) 111 foreach (ThreadTrackerItem tti in new ArrayList(m_Threads))
109 { 112 {
110 if (tti.Thread.IsAlive) 113 try
111 { 114 {
112 // Its active 115
113 tti.LastSeenActive = DateTime.Now.Ticks; 116
117 if (tti.Thread.IsAlive)
118 {
119 // Its active
120 tti.LastSeenActive = DateTime.Now.Ticks;
121 }
122 else
123 {
124 // Its not active -- if its expired then remove it
125 if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks)
126 m_Threads.Remove(tti);
127 }
114 } 128 }
115 else 129 catch (NullReferenceException)
116 { 130 {
117 // Its not active -- if its expired then remove it 131 m_Threads.Remove(tti);
118 if (tti.LastSeenActive + ThreadTimeout < DateTime.Now.Ticks)
119 m_Threads.Remove(tti);
120 } 132 }
121 } 133 }
122 } 134 }