CapyKit Documentation
  • Introduction
  • Getting Started
  • API Reference
    • CapyKit
      • CapyEventArgs
      • CapyEventHandler
      • CapyEventReporter
      • Color
      • EncryptedValue<T>
      • EventLevel
      • IPasswordAlgorithm
      • NamedColor
      • Password
      • Pbkdf2Algorithm
      • PoolItem<T>
      • Pool<T>
      • PropertyComparer<T, U>
    • CapyKit.Attributes
      • EnumerationAttribute<T>
      • EnumerationDescriptionAttribute
      • ValueFormatAttribute
    • CapyKit.Enumerations
      • MeasurementSystem
    • CapyKit.Extensions
      • EnumerationExtensions
      • LINQExtensions
      • ObjectExtensions
      • StringExtensions
    • CapyKit.Helpers
      • CalculationHelper
      • CompressionHelper
      • EncryptionHelper
      • IEncryptionAlgorithm
      • KeyHelper
      • LanguageHelper
      • SecurityHelper
      • SerializationHelper
      • SettingsHelper
      • ValidCharacterCollection
Search Results for

    Show / Hide Table of Contents
    • Introduction
    • Getting Started
    • API Reference
      • CapyKit
        • CapyEventArgs
        • CapyEventHandler
        • CapyEventReporter
        • Color
        • EncryptedValue<T>
        • EventLevel
        • IPasswordAlgorithm
        • NamedColor
        • Password
        • Pbkdf2Algorithm
        • PoolItem<T>
        • Pool<T>
        • PropertyComparer<T, U>
      • CapyKit.Attributes
        • EnumerationAttribute<T>
        • EnumerationDescriptionAttribute
        • ValueFormatAttribute
      • CapyKit.Enumerations
        • MeasurementSystem
      • CapyKit.Extensions
        • EnumerationExtensions
        • LINQExtensions
        • ObjectExtensions
        • StringExtensions
      • CapyKit.Helpers
        • CalculationHelper
        • CompressionHelper
        • EncryptionHelper
        • IEncryptionAlgorithm
        • KeyHelper
        • LanguageHelper
        • SecurityHelper
        • SerializationHelper
        • SettingsHelper
        • ValidCharacterCollection

    Class Pool<T>

    A managed pool of resources. This class provides a thread-safe way to manage a collection of objects of type T.

    Inheritance
    object
    Pool<T>
    Namespace: CapyKit
    Assembly: CapyKit.dll
    Syntax
    public class Pool<T>
    Type Parameters
    Name Description
    T

    The type of objects to be managed by the pool.

    Constructors

    Pool(IEnumerable<T>)

    Initializes a new instance of the Pool<T> class with the specified collection of items.

    Declaration
    public Pool(IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> collection

    The collection of T items with which to seed the pool.

    Pool(int)

    Initializes a new instance of the Pool<T> class with the specified pool size.

    Declaration
    public Pool(int poolSize)
    Parameters
    Type Name Description
    int poolSize

    The size of the pool.

    Pool(int, Func<T>)

    Initializes a new instance of the Pool<T> class with the specified pool size and constructor selector.

    Declaration
    public Pool(int poolSize, Func<T> constructorSelector)
    Parameters
    Type Name Description
    int poolSize

    The size of the pool.

    Func<T> constructorSelector

    The constructor selector used to create new instances of T.

    Methods

    GetAvailableItem()

    Gets the first available item from the pool and sets its lock.

    Declaration
    public PoolItem<T> GetAvailableItem()
    Returns
    Type Description
    PoolItem<T>

    The first available item from the pool.

    ReleaseItem(PoolItem<T>)

    Releases the lock on the specified item and returns it to the pool.

    Declaration
    public void ReleaseItem(PoolItem<T> item)
    Parameters
    Type Name Description
    PoolItem<T> item

    The item to release.

    Remarks

    This method sets the Locked flag to false so that it can be retrieved by GetAvailableItem().

    In this article
    Back to top Generated by DocFX