• CacheManager
  • Documentation
  • Api Docs
  • MichaCo.net
    Show / Hide Table of Contents

    Class ObjectPool<T>

    Simple policy based pool for objects.

    Inheritance
    Object
    ObjectPool<T>
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace:CacheManager.Core.Utility
    Assembly:CacheManager.Core.dll
    Syntax
    public class ObjectPool<T>
    
        where T : class
    Type Parameters
    Name Description
    T

    The object type to pool.

    Constructors

    | Improve this Doc View Source

    ObjectPool(IObjectPoolPolicy<T>, Nullable<Int32>)

    Initializes a new instance of the ObjectPool<T> class.

    Declaration
    public ObjectPool(IObjectPoolPolicy<T> policy, int ? maxItems = null)
    Parameters
    Type Name Description
    IObjectPoolPolicy<T> policy

    The object pool policy.

    Nullable<Int32> maxItems

    Number of items to keep, defaults to number of processors * 2.

    Methods

    | Improve this Doc View Source

    Lease()

    Returns either a pooled or new instance of T.

    Declaration
    public T Lease()
    Returns
    Type Description
    T

    The pooled or new instance.

    | Improve this Doc View Source

    Return(T)

    Returns the instance to the pool (if possible).

    Declaration
    public void Return(T value)
    Parameters
    Type Name Description
    T value

    The instance to return to the pool.

    • Improve this Doc
    • View Source
    © 2025 by Michael Conrad. All rights reserved. - MichaCo.net