Search Results for

    Show / Hide Table of Contents

    Class PoolExtensions

    Inheritance
    Object
    PoolExtensions
    Namespace: MackySoft.XPool
    Assembly: cs.temp.dll.dll
    Syntax
    public static class PoolExtensions

    Methods

    BindTo(IPool, IReadOnlyTimer, Int32)

    Bind the pool to the timer and releases an instances in the pool each time the callback is called.

    Declaration
    public static IDisposable BindTo(this IPool pool, IReadOnlyTimer timer, int keep)
    Parameters
    Type Name Description
    IPool pool

    Target pool.

    IReadOnlyTimer timer

    Timer to be bound to the pool.

    Int32 keep

    Quantity that keep pooled instances when release instances.

    Returns
    Type Description
    IDisposable

    Clear(IPool)

    Release the all pooled instances.

    Declaration
    public static void Clear(this IPool pool)
    Parameters
    Type Name Description
    IPool pool

    ReleaseInstancesPeriodically(IPool, Single, Int32)

    Periodically release instances in the pool.

    Declaration
    public static IDisposable ReleaseInstancesPeriodically(this IPool pool, float interval, int keep)
    Parameters
    Type Name Description
    IPool pool

    Target pool.

    Single interval

    Time interval to release an instances in the pool.

    Int32 keep

    Quantity that keep pooled instances when release instances.

    Returns
    Type Description
    IDisposable

    RentTemporary<T>(IPool<T>, out T)

    Temporary rent an instance from pool. By using the using statement, you can safely return instance.

    using (myPool.RentTemporary(out var instance)) {
        // Use instance...
    }
    Declaration
    public static RentInstance<T> RentTemporary<T>(this IPool<T> pool, out T instance)
    Parameters
    Type Name Description
    IPool<T> pool
    T instance
    Returns
    Type Description
    RentInstance<T>
    Type Parameters
    Name Description
    T

    Return<T>(IPool<T>, ref T)

    Return the instance to the pool and set reference to null.

    Declaration
    public static void Return<T>(this IPool<T> pool, ref T instance)
    Parameters
    Type Name Description
    IPool<T> pool
    T instance
    Type Parameters
    Name Description
    T
    In This Article
    Back to top XPool - Object Pooling System