Class ObjectPool<T>
对象池管理类
Inheritance
System.Object
ObjectPool<T>
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: FreeSql.Internal.ObjectPool
Assembly: FreeSql.dll
Syntax
public class ObjectPool<T> : IObjectPool<T>, IDisposable
Type Parameters
| Name | Description |
|---|---|
| T | 对象类型 |
Constructors
| Improve this Doc View SourceObjectPool(IPolicy<T>)
创建对象池
Declaration
public ObjectPool(IPolicy<T> policy)
Parameters
| Type | Name | Description |
|---|---|---|
| IPolicy<T> | policy | 策略 |
ObjectPool(Int32, Func<T>, Action<Object<T>>)
创建对象池
Declaration
public ObjectPool(int poolsize, Func<T> createObject, Action<Object<T>> onGetObject = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | poolsize | 池大小 |
| System.Func<T> | createObject | 池内对象的创建委托 |
| System.Action<Object<T>> | onGetObject | 获取池内对象成功后,进行使用前操作 |
Properties
| Improve this Doc View SourceAvailableTime
Declaration
public DateTime? AvailableTime { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.DateTime> |
IsAvailable
Declaration
public bool IsAvailable { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Policy
Declaration
public IPolicy<T> Policy { get; protected set; }
Property Value
| Type | Description |
|---|---|
| IPolicy<T> |
Statistics
Declaration
public string Statistics { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
StatisticsFullily
Declaration
public string StatisticsFullily { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
UnavailableException
Declaration
public Exception UnavailableException { get; }
Property Value
| Type | Description |
|---|---|
| System.Exception |
UnavailableTime
Declaration
public DateTime? UnavailableTime { get; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.DateTime> |
Methods
| Improve this Doc View SourceAutoFree()
Declaration
public void AutoFree()
Dispose()
Declaration
public void Dispose()
Get(Nullable<TimeSpan>)
Declaration
public Object<T> Get(TimeSpan? timeout = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Nullable<System.TimeSpan> | timeout |
Returns
| Type | Description |
|---|---|
| Object<T> |
GetAsync()
Declaration
public async Task<Object<T>> GetAsync()
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<Object<T>> |
LiveCheckAvailable()
Declaration
protected bool LiveCheckAvailable()
Returns
| Type | Description |
|---|---|
| System.Boolean |
Return(Object<T>, Boolean)
Declaration
public void Return(Object<T> obj, bool isReset = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Object<T> | obj | |
| System.Boolean | isReset |
SetUnavailable(Exception, DateTime)
Declaration
public bool SetUnavailable(Exception exception, DateTime lastGetTime)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Exception | exception | |
| System.DateTime | lastGetTime |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Implements
System.IDisposable