PoolWithDisposable<T> 类
静态通用对象池,用于存储实现了 IDisposable 接口的对象。
实现
继承成员
命名空间: Fantasy.Pool
程序集: Fantasy.Net.dll
语法
public abstract class PoolWithDisposable<T> : IDisposable where T : IPool, IDisposable, new()
类型参数
名称 | 描述 |
---|---|
T | 要存储在对象池中的对象类型,必须实现 IDisposable 接口。 |
构造函数
| 编辑本文 查看源代码PoolWithDisposable(int)
构造函数
声明
protected PoolWithDisposable(int maxCapacity)
参数
类型 | 名称 | 描述 |
---|---|---|
int | maxCapacity | 初始的容量 |
属性
| 编辑本文 查看源代码Count
池子里可用的数量
声明
public int Count { get; }
属性值
类型 | 描述 |
---|---|
int |
方法
| 编辑本文 查看源代码Dispose()
销毁方法
声明
public virtual void Dispose()
Rent()
租借
声明
public T Rent()
返回
类型 | 描述 |
---|---|
T |
Rent(Func<T>)
租借
声明
public T Rent(Func<T> generator)
参数
类型 | 名称 | 描述 |
---|---|---|
Func<T> | generator |
返回
类型 | 描述 |
---|---|
T |
Return(T)
返还
声明
public void Return(T t)
参数
类型 | 名称 | 描述 |
---|---|---|
T | t |
Return(T, Action<T>)
返还
声明
public void Return(T t, Action<T> reset)
参数
类型 | 名称 | 描述 |
---|---|---|
T | t | |
Action<T> | reset |