T
- The type of object to reuse.public final class ObjectPool<T extends ICleanable>
extends java.lang.Object
Constructor and Description |
---|
ObjectPool(Factory<T> factory)
Initializes a new
ObjectPool instance |
Modifier and Type | Method and Description |
---|---|
T |
get()
Gets the item from the pool, if pool is empty default object factory is used
|
T |
get(Factory<T> factory)
Gets the item from the pool, if pool is empty default object factory is used
|
boolean |
isEmpty()
Get the value indicating whether the pool is empty
|
void |
put(T item)
Put item into pool for further reusing
|
int |
size()
Gets the size of pool
|
public ObjectPool(Factory<T> factory)
ObjectPool
instancefactory
- The default factory which allows to create new instances for poolingpublic final int size()
public final boolean isEmpty()
public final T get()
public final T get(Factory<T> factory)
factory
- The factory to use if pool doesn't have enough itemspublic final void put(T item)
item
- The item to put into this pool