Package com.tenio.common.logger.pool
Class StringBuilderPool
java.lang.Object
com.tenio.common.logger.pool.StringBuilderPool
- All Implemented Interfaces:
ElementPool<StringBuilder>
@ThreadSafe
public final class StringBuilderPool
extends Object
implements ElementPool<StringBuilder>
The object pool mechanism for
StringBuilder
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Clean up, after that all array elements will be set to null.get()
Retrieves an element in the current pool.int
Retrieves the current available slots.static StringBuilderPool
Preventing Singleton object instantiation from outside creates multiple instance if two thread access this method simultaneously.int
Retrieves the pool size.void
repay
(StringBuilder element) When you finished using an element, repay (free) it for the reusing.
-
Method Details
-
getInstance
Preventing Singleton object instantiation from outside creates multiple instance if two thread access this method simultaneously.- Returns:
- the instance of this class
-
get
Description copied from interface:ElementPool
Retrieves an element in the current pool.- Specified by:
get
in interfaceElementPool<StringBuilder>
- Returns:
- an element in the pool
-
repay
Description copied from interface:ElementPool
When you finished using an element, repay (free) it for the reusing.- Specified by:
repay
in interfaceElementPool<StringBuilder>
- Parameters:
element
- the finished using element
-
cleanup
public void cleanup()Description copied from interface:ElementPool
Clean up, after that all array elements will be set to null.- Specified by:
cleanup
in interfaceElementPool<StringBuilder>
-
getPoolSize
public int getPoolSize()Description copied from interface:ElementPool
Retrieves the pool size.- Specified by:
getPoolSize
in interfaceElementPool<StringBuilder>
- Returns:
- the total number of element or -1 if any exceptions caused
-
getAvailableSlot
public int getAvailableSlot()Description copied from interface:ElementPool
Retrieves the current available slots.- Specified by:
getAvailableSlot
in interfaceElementPool<StringBuilder>
- Returns:
- the number of available slots in the pool
-