aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorMelanie2013-06-23 01:59:57 +0100
committerMelanie2013-06-23 01:59:57 +0100
commitf70357eaa355b8c152f3d793d0fceafa14df5fd4 (patch)
treeffda32c340bd7f6d69652e9d9a959c7396f42a2f /OpenSim/Framework/Util.cs
parentMerge branch 'avination-current' into careminster (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-f70357eaa355b8c152f3d793d0fceafa14df5fd4.zip
opensim-SC-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.gz
opensim-SC-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.bz2
opensim-SC-f70357eaa355b8c152f3d793d0fceafa14df5fd4.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Framework/Monitoring/BaseStatsCollector.cs OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs104
1 files changed, 41 insertions, 63 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 0852b49..7675be8 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -89,9 +89,30 @@ namespace OpenSim.Framework
89 } 89 }
90 90
91 /// <summary> 91 /// <summary>
92 /// Class for delivering SmartThreadPool statistical information
93 /// </summary>
94 /// <remarks>
95 /// We do it this way so that we do not directly expose STP.
96 /// </remarks>
97 public class STPInfo
98 {
99 public string Name { get; set; }
100 public STPStartInfo STPStartInfo { get; set; }
101 public WIGStartInfo WIGStartInfo { get; set; }
102 public bool IsIdle { get; set; }
103 public bool IsShuttingDown { get; set; }
104 public int MaxThreads { get; set; }
105 public int MinThreads { get; set; }
106 public int InUseThreads { get; set; }
107 public int ActiveThreads { get; set; }
108 public int WaitingCallbacks { get; set; }
109 public int MaxConcurrentWorkItems { get; set; }
110 }
111
112 /// <summary>
92 /// Miscellaneous utility functions 113 /// Miscellaneous utility functions
93 /// </summary> 114 /// </summary>
94 public class Util 115 public static class Util
95 { 116 {
96 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 117 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
97 118
@@ -1864,74 +1885,31 @@ namespace OpenSim.Framework
1864 } 1885 }
1865 1886
1866 /// <summary> 1887 /// <summary>
1867 /// Get a thread pool report. 1888 /// Get information about the current state of the smart thread pool.
1868 /// </summary> 1889 /// </summary>
1869 /// <returns></returns> 1890 /// <returns>
1870 public static string GetThreadPoolReport() 1891 /// null if this isn't the pool being used for non-scriptengine threads.
1892 /// </returns>
1893 public static STPInfo GetSmartThreadPoolInfo()
1871 { 1894 {
1872 string threadPoolUsed = null; 1895 if (m_ThreadPool == null)
1873 int maxThreads = 0; 1896 return null;
1874 int minThreads = 0;
1875 int allocatedThreads = 0;
1876 int inUseThreads = 0;
1877 int waitingCallbacks = 0;
1878 int completionPortThreads = 0;
1879
1880 StringBuilder sb = new StringBuilder();
1881 if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
1882 {
1883 // ROBUST currently leaves this the FireAndForgetMethod but never actually initializes the threadpool.
1884 if (m_ThreadPool != null)
1885 {
1886 threadPoolUsed = "SmartThreadPool";
1887 maxThreads = m_ThreadPool.MaxThreads;
1888 minThreads = m_ThreadPool.MinThreads;
1889 inUseThreads = m_ThreadPool.InUseThreads;
1890 allocatedThreads = m_ThreadPool.ActiveThreads;
1891 waitingCallbacks = m_ThreadPool.WaitingCallbacks;
1892 }
1893 }
1894 else if (
1895 FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem
1896 || FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
1897 {
1898 threadPoolUsed = "BuiltInThreadPool";
1899 ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads);
1900 ThreadPool.GetMinThreads(out minThreads, out completionPortThreads);
1901 int availableThreads;
1902 ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads);
1903 inUseThreads = maxThreads - availableThreads;
1904 allocatedThreads = -1;
1905 waitingCallbacks = -1;
1906 }
1907 1897
1908 if (threadPoolUsed != null) 1898 STPInfo stpi = new STPInfo();
1909 { 1899 stpi.Name = m_ThreadPool.Name;
1910 sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); 1900 stpi.STPStartInfo = m_ThreadPool.STPStartInfo;
1911 sb.AppendFormat("Max threads : {0}\n", maxThreads); 1901 stpi.IsIdle = m_ThreadPool.IsIdle;
1912 sb.AppendFormat("Min threads : {0}\n", minThreads); 1902 stpi.IsShuttingDown = m_ThreadPool.IsShuttingdown;
1913 sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString()); 1903 stpi.MaxThreads = m_ThreadPool.MaxThreads;
1914 sb.AppendFormat("In use threads : {0}\n", inUseThreads); 1904 stpi.MinThreads = m_ThreadPool.MinThreads;
1915 sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString()); 1905 stpi.InUseThreads = m_ThreadPool.InUseThreads;
1916 } 1906 stpi.ActiveThreads = m_ThreadPool.ActiveThreads;
1917 else 1907 stpi.WaitingCallbacks = m_ThreadPool.WaitingCallbacks;
1918 { 1908 stpi.MaxConcurrentWorkItems = m_ThreadPool.Concurrency;
1919 sb.AppendFormat("Thread pool not used\n");
1920 }
1921 1909
1922 return sb.ToString(); 1910 return stpi;
1923 } 1911 }
1924 1912
1925// private static object SmartThreadPoolCallback(object o)
1926// {
1927// object[] array = (object[])o;
1928// WaitCallback callback = (WaitCallback)array[0];
1929// object obj = array[1];
1930//
1931// callback(obj);
1932// return null;
1933// }
1934
1935 #endregion FireAndForget Threading Pattern 1913 #endregion FireAndForget Threading Pattern
1936 1914
1937 /// <summary> 1915 /// <summary>