Search Results for

    Show / Hide Table of Contents

    Class FactoryPool<T>

    Pool that create an instance from a custom factory method.

    Inheritance
    Object
    FactoryPool<T>
    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, will be thrown.

    Func<T> factory

    Method that create new instance. If is null, will be thrown. This method is must return not null. If returns null, throw .

    Action<T> onRent

    Callback that is called when is successful.

    Action<T> onReturn

    Callback that is called when is successful.

    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
    In This Article
    Back to top XPool - Object Pooling System