Package com.ning.compress
Class BufferRecycler
java.lang.Object
com.ning.compress.BufferRecycler
Simple helper class to encapsulate details of basic buffer
recycling scheme, which helps a lot (as per profiling) for
smaller encoding cases.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
private byte[]
private int[]
private byte[]
private byte[]
protected static final ThreadLocal
<SoftReference<BufferRecycler>> ThisThreadLocal
contains aSoftReference
to aBufferRecycler
used to provide a low-cost buffer recycling for buffers we need for encoding, decoding.private static final int
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
allocDecodeBuffer
(int size) byte[]
allocEncodingBuffer
(int minSize) int[]
allocEncodingHash
(int suggestedSize) byte[]
allocInputBuffer
(int minSize) byte[]
allocOutputBuffer
(int minSize) static BufferRecycler
instance()
Accessor to get thread-local recycler instancevoid
releaseDecodeBuffer
(byte[] buffer) void
releaseEncodeBuffer
(byte[] buffer) void
releaseEncodingHash
(int[] buffer) void
releaseInputBuffer
(byte[] buffer) void
releaseOutputBuffer
(byte[] buffer)
-
Field Details
-
MIN_ENCODING_BUFFER
private static final int MIN_ENCODING_BUFFER- See Also:
-
MIN_OUTPUT_BUFFER
private static final int MIN_OUTPUT_BUFFER- See Also:
-
_recyclerRef
ThisThreadLocal
contains aSoftReference
to aBufferRecycler
used 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
-
-
Constructor Details
-
BufferRecycler
public BufferRecycler()
-
-
Method Details
-
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)
-