Table of Contents

Class ParameterizedObjectPool<TKey, TValue>

Namespace
CodeProject.ObjectPool
Assembly
CodeProject.ObjectPool.dll

A parameterized version of the ObjectPool class.

public class ParameterizedObjectPool<TKey, TValue> : IParameterizedObjectPool<TKey, TValue> where TKey : notnull where TValue : PooledObject

Type Parameters

TKey

The type of the pool parameter.

TValue

The type of the objects stored in the pool.

Inheritance
ParameterizedObjectPool<TKey, TValue>
Implements
Inherited Members

Constructors

ParameterizedObjectPool()

Initializes a new pool with default settings.

public ParameterizedObjectPool()

ParameterizedObjectPool(Func<TKey, TValue>?)

Initializes a new pool with specified factory method.

public ParameterizedObjectPool(Func<TKey, TValue>? factoryMethod)

Parameters

factoryMethod Func<TKey, TValue>

The factory method that will be used to create new objects.

ParameterizedObjectPool(int)

Initializes a new pool with specified maximum pool size.

public ParameterizedObjectPool(int maximumPoolSize)

Parameters

maximumPoolSize int

The maximum pool size limit.

ParameterizedObjectPool(int, Func<TKey, TValue>?)

Initializes a new pool with specified factory method and maximum size.

public ParameterizedObjectPool(int maximumPoolSize, Func<TKey, TValue>? factoryMethod)

Parameters

maximumPoolSize int

The maximum pool size limit.

factoryMethod Func<TKey, TValue>

The factory method that will be used to create new objects.

Properties

Diagnostics

Gets or sets the Diagnostics class for the current Object Pool, whose goal is to record data about how the pool operates. By default, however, an object pool records anything, in order to be most efficient; in any case, you can enable it through the Enabled property.

public ObjectPoolDiagnostics Diagnostics { get; set; }

Property Value

ObjectPoolDiagnostics

FactoryMethod

Gets the Factory method that will be used for creating new objects.

public Func<TKey, TValue>? FactoryMethod { get; }

Property Value

Func<TKey, TValue>

KeysInPoolCount

Gets the count of the keys currently handled by the pool.

public int KeysInPoolCount { get; }

Property Value

int

MaximumPoolSize

Gets or sets the maximum number of objects that could be available at the same time in the pool.

public int MaximumPoolSize { get; set; }

Property Value

int

Methods

Clear()

Clears the parameterized pool and each inner pool stored inside it.

public void Clear()

GetObject(TKey)

Gets an object linked to given key.

public TValue GetObject(TKey key)

Parameters

key TKey

The key linked to the object.

Returns

TValue

The objects linked to given key.