ObjectPool

ObjectPool(Func<T>, Action<T>, Action<T>, Action<T>, bool, int, int)

public ObjectPool(Func<T> createFunc, Action<T> actionOnGet, Action<T> actionOnRelease, Action<T> actionOnDestroy, bool collectionCheck, int defaultCapacity, int maxSize) ;

Description

Creates a new ObjectPool instance.

Parameters

Parameter Name Description
createFunc Used to create a new instance when the pool is empty.
actionOnGet Actions called when an instance is taken out of the pool
actionOnRelease Action to be called when the instance is returned to the pool
actionOnDestroy Action called to destroy an instance because the pool has reached its maximum size
collectionCheck Flag to check if the instance is already stored when it is returned to the pool
defaultCapacity The default capacity at which the stack is created
maxSize Maximum size of the pool. When the pool reaches its maximum size, the instances you try to return to the pool will be ignored and garbage collected.