Package org.codehaus.jackson.util
Class BufferRecycler
- java.lang.Object
-
- org.codehaus.jackson.util.BufferRecycler
-
public class BufferRecycler extends Object
This is a small utility class, whose main functionality is to allow simple reuse of raw byte/char buffers. It is usually used throughThreadLocal
member of the owning class pointing to instance of this class through aSoftReference
. The end result is a low-overhead GC-cleanable recycling: hopefully ideal for use by stream readers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BufferRecycler.ByteBufferType
static class
BufferRecycler.CharBufferType
-
Field Summary
Fields Modifier and Type Field Description protected byte[][]
_byteBuffers
protected char[][]
_charBuffers
static int
DEFAULT_WRITE_CONCAT_BUFFER_LEN
-
Constructor Summary
Constructors Constructor Description BufferRecycler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
allocByteBuffer(BufferRecycler.ByteBufferType type)
char[]
allocCharBuffer(BufferRecycler.CharBufferType type)
char[]
allocCharBuffer(BufferRecycler.CharBufferType type, int minSize)
void
releaseByteBuffer(BufferRecycler.ByteBufferType type, byte[] buffer)
void
releaseCharBuffer(BufferRecycler.CharBufferType type, char[] buffer)
-
-
-
Field Detail
-
DEFAULT_WRITE_CONCAT_BUFFER_LEN
public static final int DEFAULT_WRITE_CONCAT_BUFFER_LEN
- See Also:
- Constant Field Values
-
_byteBuffers
protected final byte[][] _byteBuffers
-
_charBuffers
protected final char[][] _charBuffers
-
-
Method Detail
-
allocByteBuffer
public final byte[] allocByteBuffer(BufferRecycler.ByteBufferType type)
-
releaseByteBuffer
public final void releaseByteBuffer(BufferRecycler.ByteBufferType type, byte[] buffer)
-
allocCharBuffer
public final char[] allocCharBuffer(BufferRecycler.CharBufferType type)
-
allocCharBuffer
public final char[] allocCharBuffer(BufferRecycler.CharBufferType type, int minSize)
-
releaseCharBuffer
public final void releaseCharBuffer(BufferRecycler.CharBufferType type, char[] buffer)
-
-