- java.lang.Object
-
- org.eclipse.parsson.BufferPoolImpl
-
- All Implemented Interfaces:
BufferPool
class BufferPoolImpl extends java.lang.Object implements BufferPool
char[] pool that pool instances of char[] which are expensive to create.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ref.WeakReference<java.util.concurrent.ConcurrentLinkedQueue<char[]>>queue
-
Constructor Summary
Constructors Constructor Description BufferPoolImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.concurrent.ConcurrentLinkedQueue<char[]>getQueue()voidrecycle(char[] t)Returns an object back to the pool.char[]take()Gets a new object from the pool.
-
-
-
Method Detail
-
take
public final char[] take()
Gets a new object from the pool.If no object is available in the pool, this method creates a new one.
- Specified by:
takein interfaceBufferPool- Returns:
- always non-null.
-
getQueue
private java.util.concurrent.ConcurrentLinkedQueue<char[]> getQueue()
-
recycle
public final void recycle(char[] t)
Returns an object back to the pool.- Specified by:
recyclein interfaceBufferPool- Parameters:
t- object to return back to the pool
-
-