Package org.oscim.utils.pool
Class SyncPool<T extends Inlist<?>>
java.lang.Object
org.oscim.utils.pool.SyncPool<T>
- Direct Known Subclasses:
TextureItem.TexturePool
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanprotected intprotected final intprotected T -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()protected booleanprotected abstract TCreates the item.protected voidget()Gets an 'item' from pool, if pool is empty a new item will be created by createItem().intgetFill()voidinit(int items) To be implemented by subclass.Release 'item' to pool.releaseAll(T item) Release 'list' to pool.
-
Field Details
-
mMaxFill
protected final int mMaxFill -
mClearItems
protected final boolean mClearItems -
mFill
protected int mFill -
mPool
-
-
Constructor Details
-
SyncPool
public SyncPool(int maxItemsInPool) -
SyncPool
public SyncPool(int maxItemsInPool, boolean clearItems)
-
-
Method Details
-
getFill
public int getFill() -
init
public void init(int items) To be implemented by subclass.- Parameters:
items- number of initial items
-
clear
public void clear() -
clearItem
- Parameters:
item- set initial state- Returns:
- 'true' when item should be added back to pool, 'false' when freeItem should be called.
-
freeItem
- Parameters:
item- release resources
-
createItem
Creates the item. To be implemented by subclass.- Returns:
- the item
-
release
Release 'item' to pool. Usage item = pool.release(item), to ensure to not keep a reference to item! -
releaseAll
Release 'list' to pool. Usage list = pool.releaseAll(list), to ensure to not keep a reference to list! -
get
Gets an 'item' from pool, if pool is empty a new item will be created by createItem().- Returns:
- the item
-