recycle2 method
Recycle a List of Poolables that this pool is capable of generating. The T instances passed must not already exist inside this or any other ObjectPool instance.
@param objects A list of objects of type T to recycle
Implementation
void recycle2(List<T> objects) {
while (objects.length + this.objectsPointer + 1 > this.desiredCapacity) {
this.resizePool();
}
final int objectsListSize = objects.length;
// Not relying on recycle(T object) because this is more performant.
for (int i = 0; i < objectsListSize; i++) {
T object = objects[i];
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!");
}
}
object.currentOwnerId = this.poolId;
this.objects[this.objectsPointer + 1 + i] = object;
}
this.objectsPointer += objectsListSize;
}