Package com.tenio.engine.ecs.pool
Class ComponentPool
- java.lang.Object
-
- com.tenio.logger.AbstractLogger
-
- com.tenio.engine.ecs.pool.ComponentPool
-
- All Implemented Interfaces:
IElementPool<IComponent>
public final class ComponentPool extends AbstractLogger implements IElementPool<IComponent>
The object pool mechanism forIComponent
.- Author:
- kong
-
-
Constructor Summary
Constructors Constructor Description ComponentPool(java.lang.Class<?> clazz)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Clean up, after that all arrays will be set to nullIComponent
get()
Retrieves an element in the current poolint
getPoolSize()
Retrieves the pool sizevoid
repay(IComponent element)
When you finished using an element, repay (free) it for the reusing
-
-
-
Method Detail
-
get
public IComponent get()
Description copied from interface:IElementPool
Retrieves an element in the current pool- Specified by:
get
in interfaceIElementPool<IComponent>
- Returns:
- an element in the pool
-
repay
public void repay(IComponent element)
Description copied from interface:IElementPool
When you finished using an element, repay (free) it for the reusing- Specified by:
repay
in interfaceIElementPool<IComponent>
- Parameters:
element
- the finished using element
-
cleanup
public void cleanup()
Description copied from interface:IElementPool
Clean up, after that all arrays will be set to null- Specified by:
cleanup
in interfaceIElementPool<IComponent>
-
getPoolSize
public int getPoolSize()
Description copied from interface:IElementPool
Retrieves the pool size- Specified by:
getPoolSize
in interfaceIElementPool<IComponent>
- Returns:
- the total number of element or -1 if any exceptions caused
-
-