diff options
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 02da7f4..a695542 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -81,12 +81,15 @@ namespace OpenSim.Framework | |||
81 | 81 | ||
82 | private static uint nextXferID = 5000; | 82 | private static uint nextXferID = 5000; |
83 | private static Random randomClass = new Random(); | 83 | private static Random randomClass = new Random(); |
84 | |||
84 | // Get a list of invalid file characters (OS dependent) | 85 | // Get a list of invalid file characters (OS dependent) |
85 | private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; | 86 | private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; |
86 | private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; | 87 | private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; |
87 | private static object XferLock = new object(); | 88 | private static object XferLock = new object(); |
88 | /// <summary>Thread pool used for Util.FireAndForget if | 89 | |
89 | /// FireAndForgetMethod.SmartThreadPool is used</summary> | 90 | /// <summary> |
91 | /// Thread pool used for Util.FireAndForget if FireAndForgetMethod.SmartThreadPool is used | ||
92 | /// </summary> | ||
90 | private static SmartThreadPool m_ThreadPool; | 93 | private static SmartThreadPool m_ThreadPool; |
91 | 94 | ||
92 | // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC. | 95 | // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC. |
@@ -144,7 +147,6 @@ namespace OpenSim.Framework | |||
144 | return lerp(y, lerp(x, a, b), lerp(x, c, d)); | 147 | return lerp(y, lerp(x, a, b), lerp(x, c, d)); |
145 | } | 148 | } |
146 | 149 | ||
147 | |||
148 | public static Encoding UTF8 = Encoding.UTF8; | 150 | public static Encoding UTF8 = Encoding.UTF8; |
149 | 151 | ||
150 | /// <value> | 152 | /// <value> |
@@ -1683,6 +1685,61 @@ namespace OpenSim.Framework | |||
1683 | } | 1685 | } |
1684 | } | 1686 | } |
1685 | 1687 | ||
1688 | /// <summary> | ||
1689 | /// Get a thread pool report. | ||
1690 | /// </summary> | ||
1691 | /// <returns></returns> | ||
1692 | public static string GetThreadPoolReport() | ||
1693 | { | ||
1694 | string threadPoolUsed = null; | ||
1695 | int maxThreads = 0; | ||
1696 | int minThreads = 0; | ||
1697 | int allocatedThreads = 0; | ||
1698 | int inUseThreads = 0; | ||
1699 | int waitingCallbacks = 0; | ||
1700 | int completionPortThreads = 0; | ||
1701 | |||
1702 | StringBuilder sb = new StringBuilder(); | ||
1703 | if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) | ||
1704 | { | ||
1705 | threadPoolUsed = "SmartThreadPool"; | ||
1706 | maxThreads = m_ThreadPool.MaxThreads; | ||
1707 | minThreads = m_ThreadPool.MinThreads; | ||
1708 | inUseThreads = m_ThreadPool.InUseThreads; | ||
1709 | allocatedThreads = m_ThreadPool.ActiveThreads; | ||
1710 | waitingCallbacks = m_ThreadPool.WaitingCallbacks; | ||
1711 | } | ||
1712 | else if ( | ||
1713 | FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem | ||
1714 | || FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem) | ||
1715 | { | ||
1716 | threadPoolUsed = "BuiltInThreadPool"; | ||
1717 | ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads); | ||
1718 | ThreadPool.GetMinThreads(out minThreads, out completionPortThreads); | ||
1719 | int availableThreads; | ||
1720 | ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads); | ||
1721 | inUseThreads = maxThreads - availableThreads; | ||
1722 | allocatedThreads = -1; | ||
1723 | waitingCallbacks = -1; | ||
1724 | } | ||
1725 | |||
1726 | if (threadPoolUsed != null) | ||
1727 | { | ||
1728 | sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed); | ||
1729 | sb.AppendFormat("Max threads : {0}\n", maxThreads); | ||
1730 | sb.AppendFormat("Min threads : {0}\n", minThreads); | ||
1731 | sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString()); | ||
1732 | sb.AppendFormat("In use threads : {0}\n", inUseThreads); | ||
1733 | sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString()); | ||
1734 | } | ||
1735 | else | ||
1736 | { | ||
1737 | sb.AppendFormat("Thread pool not used\n"); | ||
1738 | } | ||
1739 | |||
1740 | return sb.ToString(); | ||
1741 | } | ||
1742 | |||
1686 | private static object SmartThreadPoolCallback(object o) | 1743 | private static object SmartThreadPoolCallback(object o) |
1687 | { | 1744 | { |
1688 | object[] array = (object[])o; | 1745 | object[] array = (object[])o; |