Add object count stats for new IncomingPacket and UDPPacketBuffer pools if they are enabled. Add count stats for existing LLUDP pool.

This introduces a pull stat type in addition to the push stat type.
A pull stat takes a method on construction which knows how to update the stat on request.
In this way, special interfaces for pull stat collection are not necessary.
This commit is contained in:
Justin Clark-Casey (justincc)
2012-10-23 01:50:05 +01:00
parent 2206132ab9
commit 4578ff74fe
6 changed files with 153 additions and 14 deletions

View File

@@ -38,8 +38,23 @@ namespace OpenSim.Framework
/// </remarks>
public class Pool<T>
{
/// <summary>
/// Number of objects in the pool.
/// </summary>
public int Count
{
get
{
lock (m_pool)
return m_pool.Count;
}
}
private Stack<T> m_pool;
/// <summary>
/// Maximum pool size. Beyond this, any returned objects are not pooled.
/// </summary>
private int m_maxPoolSize;
private Func<T> m_createFunction;