Top Description Fields Constructors Methods
com.ning.compress

public final Class BufferRecycler

extends Object
Class Inheritance
Imports
java.lang.ref.SoftReference

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 ([email protected])

Field Summary

Modifier and TypeField and Description
private byte[]
private byte[]
private int[]
private byte[]
private byte[]
protected static final ThreadLocal<SoftReference<BufferRecycler>>
_recyclerRef

This ThreadLocal contains a java.lang.ref.SoftReference to a BufferRecycler 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

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public byte[]
public byte[]
allocEncodingBuffer(int minSize)

public int[]
allocEncodingHash(int suggestedSize)

public byte[]
allocInputBuffer(int minSize)

public byte[]
allocOutputBuffer(int minSize)

public static BufferRecycler
instance()

Accessor to get thread-local recycler instance

public void
releaseDecodeBuffer(byte[] buffer)

public void
releaseEncodeBuffer(byte[] buffer)

public void
releaseEncodingHash(int[] buffer)

public void
releaseInputBuffer(byte[] buffer)

public void
releaseOutputBuffer(byte[] buffer)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_decodingBufferback to summary
private byte[] _decodingBuffer
_encodingBufferback to summary
private byte[] _encodingBuffer
_encodingHashback to summary
private int[] _encodingHash
_inputBufferback to summary
private byte[] _inputBuffer
_outputBufferback to summary
private byte[] _outputBuffer
_recyclerRefback to summary
protected static final ThreadLocal<SoftReference<BufferRecycler>> _recyclerRef

This ThreadLocal contains a java.lang.ref.SoftReference to a BufferRecycler used to provide a low-cost buffer recycling for buffers we need for encoding, decoding.

MIN_ENCODING_BUFFERback to summary
private static final int MIN_ENCODING_BUFFER
MIN_OUTPUT_BUFFERback to summary
private static final int MIN_OUTPUT_BUFFER

Constructor Detail

BufferRecyclerback to summary
public BufferRecycler()

Method Detail

allocDecodeBufferback to summary
public byte[] allocDecodeBuffer(int size)
allocEncodingBufferback to summary
public byte[] allocEncodingBuffer(int minSize)
allocEncodingHashback to summary
public int[] allocEncodingHash(int suggestedSize)
allocInputBufferback to summary
public byte[] allocInputBuffer(int minSize)
allocOutputBufferback to summary
public byte[] allocOutputBuffer(int minSize)
instanceback to summary
public static BufferRecycler instance()

Accessor to get thread-local recycler instance

releaseDecodeBufferback to summary
public void releaseDecodeBuffer(byte[] buffer)
releaseEncodeBufferback to summary
public void releaseEncodeBuffer(byte[] buffer)
releaseEncodingHashback to summary
public void releaseEncodingHash(int[] buffer)
releaseInputBufferback to summary
public void releaseInputBuffer(byte[] buffer)
releaseOutputBufferback to summary
public void releaseOutputBuffer(byte[] buffer)