public class ConcurrentReflectionPool<T> extends org.mini2Dx.gdx.utils.ReflectionPool<T> implements ConcurrentCollection
Modifier and Type | Field and Description |
---|---|
protected ReadWriteLock |
lock |
Constructor and Description |
---|
ConcurrentReflectionPool(java.lang.Class<T> type) |
ConcurrentReflectionPool(java.lang.Class<T> type,
int initialCapacity) |
ConcurrentReflectionPool(java.lang.Class<T> type,
int initialCapacity,
int max) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all free objects from this pool.
|
void |
free(T object)
Puts the specified object in the pool, making it eligible to be returned by
obtain() . |
void |
freeAll(org.mini2Dx.gdx.utils.Array<T> objects)
Puts the specified objects in the pool.
|
int |
getFree()
The number of objects available to be obtained.
|
ReadWriteLock |
getLock()
Returns the collection's
ReadWriteLock |
T |
obtain()
Returns an object from this pool.
|
protected void |
reset(T object)
Called when an object is freed to clear the state of the object for possible later reuse.
|
protected ReadWriteLock lock
public ConcurrentReflectionPool(java.lang.Class<T> type)
public ConcurrentReflectionPool(java.lang.Class<T> type, int initialCapacity)
public ConcurrentReflectionPool(java.lang.Class<T> type, int initialCapacity, int max)
public T obtain()
ReflectionPool.newObject()
) or reused (previously
freed
).obtain
in class org.mini2Dx.gdx.utils.Pool<T>
public void free(T object)
obtain()
. If the pool already contains
Pool.max
free objects, the specified object is reset but not added to the pool.
The pool does not check if an object is already freed, so the same object must not be freed multiple times.
free
in class org.mini2Dx.gdx.utils.Pool<T>
object
- protected void reset(T object)
Poolable#reset()
if the object is Poolable
.reset
in class org.mini2Dx.gdx.utils.Pool<T>
object
- public void freeAll(org.mini2Dx.gdx.utils.Array<T> objects)
The pool does not check if an object is already freed, so the same object must not be freed multiple times.
freeAll
in class org.mini2Dx.gdx.utils.Pool<T>
objects
- free(Object)
public void clear()
clear
in class org.mini2Dx.gdx.utils.Pool<T>
public int getFree()
getFree
in class org.mini2Dx.gdx.utils.Pool<T>
public ReadWriteLock getLock()
ConcurrentCollection
ReadWriteLock
getLock
in interface ConcurrentCollection
ReadWriteLock