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
initialCapacity | The 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
initialCapacity | The initial capacity of the pool. |
maxCapacity | The maximum number of objects that can be generated. |
reuseActive | Whether 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
generator | The function delegate that generates a new object. |
initialCapacity | The 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
generator | The function delegate that generates a new object. |
initialCapacity | The initial capacity of the pool. |
maxCapacity | The maximum number of objects that can be generated. |
reuseActive | Whether active objects should be reused when the object pool has reached max capacity. |