releaseIntoPool method

FutureOr<bool> releaseIntoPool(
  1. C o
)
inherited

Implementation

FutureOr<bool> releaseIntoPool(O o) {
  var ret = recyclePoolElement(o);

  return ret.resolveMapped((recycled) {
    if (recycled == null) {
      ++_unrecycledElementsCount;
      disposePoolElement(o);
      return false;
    }

    callCheckPool();
    _pool.addLast(recycled);

    while (_yields.isNotEmpty) {
      var yield = _yields.removeFirst();
      if (!yield.isCompleted) {
        yield.complete(true);
        break;
      }
    }

    var waitingPoolElement = _waitingPoolElement;
    if (waitingPoolElement != null && !waitingPoolElement.isCompleted) {
      waitingPoolElement.complete(true);
      _waitingPoolElement = null;
    }

    return true;
  });
}