recycle1 method

void recycle1(
  1. T object
)

Recycle an instance of Poolable that this pool is capable of generating. The T instance passed must not already exist inside this or any other ObjectPool instance.

@param object An object of type T to recycle

Implementation

void recycle1(T object) {
  if (object.currentOwnerId != PoolAble.NO_OWNER) {
    if (object.currentOwnerId == this.poolId) {
      throw Exception(
          "The object passed is already stored in this pool!");
    } else {
      throw Exception(
          "The object to recycle already belongs to poolId ${object.currentOwnerId}.  Object cannot belong to two different pool instances simultaneously!");
    }
  }

  this.objectsPointer++;
  if (this.objectsPointer >= objects.length) {
    this.resizePool();
  }

  object.currentOwnerId = this.poolId;
  objects[this.objectsPointer] = object;
}