CapicityPool.cs 893 B

12345678910111213141516171819202122232425262728293031
  1. namespace IFramework
  2. {
  3. /// <summary>
  4. /// 有容量的对象池
  5. /// </summary>
  6. /// <typeparam name="T"></typeparam>
  7. public abstract class CapicityPool<T>: ObjectPool<T>
  8. {
  9. private int _capcity;
  10. /// <summary>
  11. /// 存储容量
  12. /// </summary>
  13. public int capcity { get { return _capcity; } set { _capcity = value; } }
  14. /// <summary>
  15. /// Ctor
  16. /// </summary>
  17. /// <param name="capcity"></param>
  18. protected CapicityPool(int capcity) : base() { this._capcity = capcity; }
  19. /// <summary>
  20. /// 回收,当数量超过回收失败
  21. /// </summary>
  22. /// <param name="t"></param>
  23. /// <param name="arg"></param>
  24. /// <returns></returns>
  25. protected override bool OnSet(T t, IEventArgs arg)
  26. {
  27. return count <= capcity;
  28. }
  29. }
  30. }