Package com.ning.compress
Class BufferRecycler
- java.lang.Object
-
- com.ning.compress.BufferRecycler
-
public final class BufferRecycler extends java.lang.ObjectSimple helper class to encapsulate details of basic buffer recycling scheme, which helps a lot (as per profiling) for smaller encoding cases.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]_decodingBufferprivate byte[]_encodingBufferprivate int[]_encodingHashprivate byte[]_inputBufferprivate byte[]_outputBufferprotected static java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>>_recyclerRefThisThreadLocalcontains aSoftReferenceto aBufferRecyclerused to provide a low-cost buffer recycling for buffers we need for encoding, decoding.private static intMIN_ENCODING_BUFFERprivate static intMIN_OUTPUT_BUFFER
-
Constructor Summary
Constructors Constructor Description BufferRecycler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]allocDecodeBuffer(int size)byte[]allocEncodingBuffer(int minSize)int[]allocEncodingHash(int suggestedSize)byte[]allocInputBuffer(int minSize)byte[]allocOutputBuffer(int minSize)static BufferRecyclerinstance()Accessor to get thread-local recycler instancevoidreleaseDecodeBuffer(byte[] buffer)voidreleaseEncodeBuffer(byte[] buffer)voidreleaseEncodingHash(int[] buffer)voidreleaseInputBuffer(byte[] buffer)voidreleaseOutputBuffer(byte[] buffer)
-
-
-
Field Detail
-
MIN_ENCODING_BUFFER
private static final int MIN_ENCODING_BUFFER
- See Also:
- Constant Field Values
-
MIN_OUTPUT_BUFFER
private static final int MIN_OUTPUT_BUFFER
- See Also:
- Constant Field Values
-
_recyclerRef
protected static final java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>> _recyclerRef
ThisThreadLocalcontains aSoftReferenceto aBufferRecyclerused to provide a low-cost buffer recycling for buffers we need for encoding, decoding.
-
_inputBuffer
private byte[] _inputBuffer
-
_outputBuffer
private byte[] _outputBuffer
-
_decodingBuffer
private byte[] _decodingBuffer
-
_encodingBuffer
private byte[] _encodingBuffer
-
_encodingHash
private int[] _encodingHash
-
-
Method Detail
-
instance
public static BufferRecycler instance()
Accessor to get thread-local recycler instance
-
allocEncodingBuffer
public byte[] allocEncodingBuffer(int minSize)
-
releaseEncodeBuffer
public void releaseEncodeBuffer(byte[] buffer)
-
allocOutputBuffer
public byte[] allocOutputBuffer(int minSize)
-
releaseOutputBuffer
public void releaseOutputBuffer(byte[] buffer)
-
allocEncodingHash
public int[] allocEncodingHash(int suggestedSize)
-
releaseEncodingHash
public void releaseEncodingHash(int[] buffer)
-
allocInputBuffer
public byte[] allocInputBuffer(int minSize)
-
releaseInputBuffer
public void releaseInputBuffer(byte[] buffer)
-
allocDecodeBuffer
public byte[] allocDecodeBuffer(int size)
-
releaseDecodeBuffer
public void releaseDecodeBuffer(byte[] buffer)
-
-