Class FactoryPool<T>
Pool that create an instance from a custom factory method.
Namespace: MackySoft.XPool
Assembly: cs.temp.dll.dll
Syntax
public sealed class FactoryPool<T> : PoolBase<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
FactoryPool(Int32, Func<T>, Action<T>, Action<T>, Action<T>)
Declaration
public FactoryPool(int capacity, Func<T> factory, Action<T> onRent = null, Action<T> onReturn = null, Action<T> onRelease = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | capacity | The pool capacity. If less than or equal to 0, |
| Func<T> | factory | Method that create new instance. If is null, |
| Action<T> | onRent | Callback that is called when |
| Action<T> | onReturn | Callback that is called when |
| Action<T> | onRelease | Callback that is called when capacity is exceeded and the instance cannot be returned to the pool. |
Methods
Factory()
Declaration
protected override T Factory()
Returns
| Type | Description |
|---|---|
| T |
OnRelease(T)
Declaration
protected override void OnRelease(T instance)
Parameters
| Type | Name | Description |
|---|---|---|
| T | instance |
OnRent(T)
Declaration
protected override void OnRent(T instance)
Parameters
| Type | Name | Description |
|---|---|---|
| T | instance |
OnReturn(T)
Declaration
protected override void OnReturn(T instance)
Parameters
| Type | Name | Description |
|---|---|---|
| T | instance |