public abstract class ConcurrentPool<T> extends org.mini2Dx.gdx.utils.Pool<T> implements ConcurrentCollection
| Modifier and Type | Field and Description |
|---|---|
protected org.mini2Dx.lockprovider.ReadWriteLock |
lock |
| Constructor and Description |
|---|
ConcurrentPool()
Creates a pool with an initial capacity of 16 and no maximum.
|
ConcurrentPool(int initialCapacity)
Creates a pool with the specified initial capacity and no maximum.
|
ConcurrentPool(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.
|
org.mini2Dx.lockprovider.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.
|
public ConcurrentPool()
public ConcurrentPool(int initialCapacity)
initialCapacity - public ConcurrentPool(int initialCapacity,
int max)
initialCapacity - max - The maximum number of free objects to store in this pool.public T obtain()
Pool.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 org.mini2Dx.lockprovider.ReadWriteLock getLock()
ConcurrentCollectionReadWriteLockgetLock in interface ConcurrentCollectionReadWriteLock