Package com.tenio.engine.ecs.pool
Class EntityPool
- java.lang.Object
-
- com.tenio.logger.AbstractLogger
-
- com.tenio.engine.ecs.pool.EntityPool
-
- All Implemented Interfaces:
IElementPool<IEntity>
public final class EntityPool extends AbstractLogger implements IElementPool<IEntity>
The object pool mechanism forIEntity
.- Author:
- kong
-
-
Constructor Summary
Constructors Constructor Description EntityPool(java.lang.Class<? extends Entity> clazz, ContextInfo contextInfo)
-
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 nullIEntity
get()
Retrieves an element in the current poolint
getPoolSize()
Retrieves the pool sizevoid
repay(IEntity element)
When you finished using an element, repay (free) it for the reusing
-
-
-
Constructor Detail
-
EntityPool
public EntityPool(java.lang.Class<? extends Entity> clazz, ContextInfo contextInfo)
-
-
Method Detail
-
get
public IEntity get()
Description copied from interface:IElementPool
Retrieves an element in the current pool- Specified by:
get
in interfaceIElementPool<IEntity>
- Returns:
- an element in the pool
-
repay
public void repay(IEntity element)
Description copied from interface:IElementPool
When you finished using an element, repay (free) it for the reusing- Specified by:
repay
in interfaceIElementPool<IEntity>
- 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<IEntity>
-
getPoolSize
public int getPoolSize()
Description copied from interface:IElementPool
Retrieves the pool size- Specified by:
getPoolSize
in interfaceIElementPool<IEntity>
- Returns:
- the total number of element or -1 if any exceptions caused
-
-