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.
- Author:
- Tatu Saloranta (tatu.saloranta@iki.fi)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ThreadLocal<SoftReference<BufferRecycler>> ThisThreadLocalcontains aSoftReferenceto aBufferRecyclerused to provide a low-cost buffer recycling for buffers we need for encoding, decoding. -
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 BufferRecyclerinstance()Accessor to get thread-local recycler instancevoidreleaseDecodeBuffer(byte[] buffer) voidreleaseEncodeBuffer(byte[] buffer) voidreleaseEncodingHash(int[] buffer) voidreleaseInputBuffer(byte[] buffer) voidreleaseOutputBuffer(byte[] buffer)
-
Field Details
-
_recyclerRef
ThisThreadLocalcontains aSoftReferenceto aBufferRecyclerused to provide a low-cost buffer recycling for buffers we need for encoding, decoding.
-
-
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)
-