GeWuYou eb763a9bc4 feat(pool): 重构对象池系统增加统计和容量控制功能
- 引入 PoolInfo 类来管理对象池的核心数据结构和统计信息
- 添加对象池容量限制功能,超过容量时自动销毁多余对象
- 实现对象池统计功能,跟踪创建、获取、释放、销毁等操作计数
- 新增 GetPoolSize 和 GetActiveCount 方法获取池状态信息
- 添加 SetMaxCapacity 方法设置池的最大容量限制
- 实现 Prewarm 功能用于预创建对象提高性能
- 提供 GetStatistics 方法获取详细的池统计信息
- 添加 IsExternalInit 支持旧版 .NET 框架的 init-only 属性
- 扩展 ArrayPool 添加便捷的扩展方法和自动释放功能
- 新增 StringBuilderPool 提供高性能的字符串构建器复用
- 完善单元测试覆盖新增的所有功能特性
2026-02-25 20:40:02 +08:00

43 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace GFramework.Core.Abstractions.pool;
/// <summary>
/// 对象池统计信息
/// </summary>
public class PoolStatistics
{
/// <summary>
/// 池中当前可用对象数量
/// </summary>
public int AvailableCount { get; init; }
/// <summary>
/// 当前活跃(已获取但未释放)的对象数量
/// </summary>
public int ActiveCount { get; init; }
/// <summary>
/// 池的最大容量限制0 表示无限制
/// </summary>
public int MaxCapacity { get; init; }
/// <summary>
/// 累计创建的对象总数
/// </summary>
public int TotalCreated { get; init; }
/// <summary>
/// 累计获取对象的次数
/// </summary>
public int TotalAcquired { get; init; }
/// <summary>
/// 累计释放对象的次数
/// </summary>
public int TotalReleased { get; init; }
/// <summary>
/// 累计销毁的对象数量(超过容量限制被销毁的对象)
/// </summary>
public int TotalDestroyed { get; init; }
}