public class ObjectPool<T extends ObjectPool.Poolable>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ObjectPool.Poolable |
| Modifier and Type | Method and Description |
|---|---|
static ObjectPool |
create(int withCapacity,
ObjectPool.Poolable object)
Returns an ObjectPool instance, of a given starting capacity, that recycles instances of a given Poolable object.
|
T |
get()
Returns an instance of Poolable.
|
int |
getPoolCapacity()
Returns the capacity of this object pool.
|
int |
getPoolCount()
Returns the number of objects remaining in the pool, for diagnostic purposes.
|
int |
getPoolId()
Returns the id of the given pool instance.
|
float |
getReplenishPercentage() |
void |
recycle(java.util.List<T> objects)
Recycle a List of Poolables that this pool is capable of generating.
|
void |
recycle(T object)
Recycle an instance of Poolable that this pool is capable of generating.
|
void |
setReplenishPercentage(float percentage)
Set the percentage of the pool to replenish on empty.
|
public int getPoolId()
public static ObjectPool create(int withCapacity, ObjectPool.Poolable object)
withCapacity - A positive integer value.object - An instance of the object that the pool should recycle.public void setReplenishPercentage(float percentage)
percentage - a value between 0 and 1, representing the percentage of the pool to replenish.public float getReplenishPercentage()
public T get()
public void recycle(T object)
object - An object of type T to recyclepublic void recycle(java.util.List<T> objects)
objects - A list of objects of type T to recyclepublic int getPoolCapacity()
public int getPoolCount()