public abstract class SyncPool<T extends Inlist<?>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
mClearItems |
protected int |
mFill |
protected int |
mMaxFill |
protected T |
mPool |
| Constructor and Description |
|---|
SyncPool(int maxItemsInPool) |
SyncPool(int maxItemsInPool,
boolean clearItems) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
protected boolean |
clearItem(T item) |
protected abstract T |
createItem()
Creates the item.
|
protected void |
freeItem(T item) |
T |
get()
Gets an 'item' from pool, if pool is empty a new
item will be created by createItem().
|
int |
getFill() |
void |
init(int items)
To be implemented by subclass.
|
T |
release(T item)
Release 'item' to pool.
|
T |
releaseAll(T item)
Release 'list' to pool.
|
protected final int mMaxFill
protected final boolean mClearItems
protected int mFill
public SyncPool(int maxItemsInPool)
public SyncPool(int maxItemsInPool,
boolean clearItems)
public int getFill()
public void init(int items)
items - number of initial itemspublic void clear()
protected boolean clearItem(T item)
item - set initial stateprotected void freeItem(T item)
item - release resourcesprotected abstract T createItem()
public T release(T item)
public T releaseAll(T item)
public T get()