PoolManager
| Modifier and Type | Class and Description |
|---|---|
| public static interface | Pool.
Objects implementing this interface will have |
| Modifier and Type | Field and Description |
|---|---|
| private final Array | |
| public final int | max
The maximum number of objects that will be pooled. |
| public int | peak
The highest number of free objects. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| protected void | |
| public void | fill(int
the number of objects to be added size)Adds the specified number of new free objects to the pool. |
| public void | |
| public void | |
| public int | |
| protected abstract T | |
| public T | |
| protected void | reset(T object)
Called when an object is freed to clear the state of the object for possible later reuse. |
| freeObjects | back to summary |
|---|---|
| private final Array<T> freeObjects | |
| max | back to summary |
|---|---|
| public final int max The maximum number of objects that will be pooled. | |
| peak | back to summary |
|---|---|
| public int peak The highest number of free objects. Can be reset any time. | |
| Pool | back to summary |
|---|---|
| public Pool() Creates a pool with an initial capacity of 16 and no maximum. | |
| Pool | back to summary |
|---|---|
| public Pool(int initialCapacity) Creates a pool with the specified initial capacity and no maximum. | |
| Pool | back to summary |
|---|---|
public Pool(int initialCapacity, int max)
| |
| clear | back to summary |
|---|---|
| public void clear() Removes and discards all free objects from this pool. | |
| discard | back to summary |
|---|---|
| protected void discard(T object) Called when an object is discarded. This is the case when an object is freed, but the maximum capacity of the pool is
reached, and when the pool is | |
| fill | back to summary |
|---|---|
| public void fill(int size) Adds the specified number of new free objects to the pool. Usually called early on as a pre-allocation mechanism but can be used at any time.
| |
| free | back to summary |
|---|---|
| public void free(T object) Puts the specified object in the pool, making it eligible to be returned by The pool does not check if an object is already freed, so the same object must not be freed multiple times. | |
| freeAll | back to summary |
|---|---|
| public void freeAll(Array<T> objects) Puts the specified objects in the pool. Null objects within the array are silently ignored. The pool does not check if an object is already freed, so the same object must not be freed multiple times.
| |
| getFree | back to summary |
|---|---|
| public int getFree() The number of objects available to be obtained. | |
| newObject | back to summary |
|---|---|
| protected abstract T newObject() | |
| obtain | back to summary |
|---|---|
| public T obtain() Returns an object from this pool. The object may be new (from | |
| reset | back to summary |
|---|---|
| protected void reset(T object) Called when an object is freed to clear the state of the object for possible later reuse. The default implementation calls
| |
reset() called when passed to Pool#free(Object).
| Modifier and Type | Method and Description |
|---|---|
| public void |
| reset | back to summary |
|---|---|
| public void reset() Resets the object for reuse. Object references should be nulled and fields may be set to default values. | |