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