Package org.glassfish.json
Class BufferPoolImpl
- java.lang.Object
-
- org.glassfish.json.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()
void
recycle(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:
take
in 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:
recycle
in interfaceBufferPool
- Parameters:
t
- object to return back to the pool
-
-