ObjectPool Constructor

Constructor in ObjectPool<T>


Declaration

public ObjectPool(int initialCapacity)

Description

Creates a new object pool with an initial capacity. New objects are created as needed using the object type default value.

Parameters

initialCapacityThe initial capacity of the pool.

Overload

Declaration

public ObjectPool(int initialCapacity, int maxCapacity, bool reuseActive = false)

Description

Creates a new object pool with an initial capacity and max capacity. Optionally active objects can be reused when the pool has reached max capacity. New objects are created as needed using the object type default value.

Parameters

initialCapacityThe initial capacity of the pool.
maxCapacityThe maximum number of objects that can be generated.
reuseActiveWhether active objects should be reused when the object pool has reached max capacity.

Overload

Declaration

public ObjectPool(ObjectPool<T>.Generator generator, int initialCapacity)

Description

Creates a new object pool with a given generator function and initial capacity. New objects are created as needed with no max capacity.

Parameters

generatorThe function delegate that generates a new object.
initialCapacityThe initial capacity of the pool.

Overload

Declaration

public ObjectPool(ObjectPool<T>.Generator generator, int initialCapacity, int maxCapacity, bool reuseActive = false)

Description

Creates a new object pool with a given generator function and set capacity limits. Optionally active objects can be reused when the pool has reached max capacity.

Parameters

generatorThe function delegate that generates a new object.
initialCapacityThe initial capacity of the pool.
maxCapacityThe maximum number of objects that can be generated.
reuseActiveWhether active objects should be reused when the object pool has reached max capacity.