diff options
author | Diva Canto | 2012-03-16 13:08:27 -0700 |
---|---|---|
committer | Diva Canto | 2012-03-16 13:08:27 -0700 |
commit | a4dca88a5718b8594177314a289eae84f2ac585e (patch) | |
tree | 2bb177ddbff71330ca02cd1abb6ba48ceb184e8a /OpenSim/Framework/Util.cs | |
parent | Terrain: added [Terrain] section with an option to load an initial flat terra... (diff) | |
parent | minor: reuse threadpool count we just fetched instead of fetching it again (diff) | |
download | opensim-SC-a4dca88a5718b8594177314a289eae84f2ac585e.zip opensim-SC-a4dca88a5718b8594177314a289eae84f2ac585e.tar.gz opensim-SC-a4dca88a5718b8594177314a289eae84f2ac585e.tar.bz2 opensim-SC-a4dca88a5718b8594177314a289eae84f2ac585e.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 31fa101..9e0f138 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -147,7 +147,6 @@ namespace OpenSim.Framework | |||
147 | return lerp(y, lerp(x, a, b), lerp(x, c, d)); | 147 | return lerp(y, lerp(x, a, b), lerp(x, c, d)); |
148 | } | 148 | } |
149 | 149 | ||
150 | |||
151 | public static Encoding UTF8 = Encoding.UTF8; | 150 | public static Encoding UTF8 = Encoding.UTF8; |
152 | 151 | ||
153 | /// <value> | 152 | /// <value> |
@@ -1674,6 +1673,61 @@ namespace OpenSim.Framework | |||
1674 | } | 1673 | } |
1675 | } | 1674 | } |
1676 | 1675 | ||
1676 | /// <summary> | ||
1677 | /// Get a thread pool report. | ||
1678 | /// </summary> | ||
1679 | /// <returns></returns> | ||
1680 | public static string GetThreadPoolReport() | ||
1681 | { | ||
1682 | string threadPoolUsed = null; | ||
1683 | int maxThreads = 0; | ||
1684 | int minThreads = 0; | ||
1685 | int allocatedThreads = 0; | ||
1686 | int inUseThreads = 0; | ||
1687 | int waitingCallbacks = 0; | ||
1688 | int completionPortThreads = 0; | ||
1689 | |||
1690 | StringBuilder sb = new StringBuilder(); | ||
1691 | if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) | ||
1692 | { | ||
1693 | threadPoolUsed = "SmartThreadPool"; | ||
1694 | maxThreads = m_ThreadPool.MaxThreads; | ||
1695 | minThreads = m_ThreadPool.MinThreads; | ||
1696 | inUseThreads = m_ThreadPool.InUseThreads; | ||
1697 | allocatedThreads = m_ThreadPool.ActiveThreads; | ||
1698 | waitingCallbacks = m_ThreadPool.WaitingCallbacks; | ||
1699 | } | ||
1700 | else if ( | ||
1701 | FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem | ||
1702 | || FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem) | ||
1703 | { | ||
1704 | threadPoolUsed = "BuiltInThreadPool"; | ||
1705 | ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads); | ||
1706 | ThreadPool.GetMinThreads(out minThreads, out completionPortThreads); | ||
1707 | int availableThreads; | ||
1708 | ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads); | ||
1709 | inUseThreads = maxThreads - availableThreads; | ||
1710 | allocatedThreads = -1; | ||
1711 | waitingCallbacks = -1; | ||
1712 | } | ||
1713 | |||
1714 | if (threadPoolUsed != null) | ||
1715 | { | ||
1716 | sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); | ||
1717 | sb.AppendFormat("Max threads : {0}\n", maxThreads); | ||
1718 | sb.AppendFormat("Min threads : {0}\n", minThreads); | ||
1719 | sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString()); | ||
1720 | sb.AppendFormat("In use threads : {0}\n", inUseThreads); | ||
1721 | sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString()); | ||
1722 | } | ||
1723 | else | ||
1724 | { | ||
1725 | sb.AppendFormat("Thread pool not used\n"); | ||
1726 | } | ||
1727 | |||
1728 | return sb.ToString(); | ||
1729 | } | ||
1730 | |||
1677 | private static object SmartThreadPoolCallback(object o) | 1731 | private static object SmartThreadPoolCallback(object o) |
1678 | { | 1732 | { |
1679 | object[] array = (object[])o; | 1733 | object[] array = (object[])o; |