acquire method

T acquire([
  1. V? data
])

Acquire a new object.

If the pool is empty it will automically grow by 20% + 1. To ensure there is always something in the pool.

The data argument will be passed to PoolObject.init when it gets acquired.

Implementation

T acquire([V? data]) {
  if (_pool.isEmpty) {
    expand((_count * 0.2).floor() + 1);
  }
  final object = _pool.removeLast();
  assert(
    data == null || data is V,
    '$T expects an instance of $V but received ${data.runtimeType}',
  );
  return object..init(data);
}