ObjectPool<T> constructor

ObjectPool<T>({
  1. required T factory(),
  2. void reset(
    1. T
    )?,
  3. int maxSize = 50,
})

Creates a new ObjectPool.

factory A function that creates new objects for the pool. reset An optional function that resets an object before it is returned to the pool. maxSize The maximum number of objects to store in the pool.

Implementation

ObjectPool({required T Function() factory, void Function(T)? reset, int maxSize = 50}) : _factory = factory, _reset = reset, _maxSize = maxSize;