Package com.fasterxml.aalto.util
Class BufferRecycler
- java.lang.Object
-
- com.fasterxml.aalto.util.BufferRecycler
-
public final class BufferRecycler extends java.lang.ObjectThis is a small utility class, whose main functionality is to allow simple reuse of raw byte/char buffers. It is usually used throughThreadLocalmember 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.Regarding implementation: the key design goal is simplicity; and to that end, different types of buffers are handled separately. While code may look inelegant as a result (would be cleaner to just have generic char[]/byte[] buffer accessors), benefit is that no data structures are needed, just simple references. As long as usage pattern is well known (which it is, for stream readers) this should be highly optimal and robust implementation.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]mFullBBufferprivate char[]mFullCBufferprivate char[]mMediumCBufferprivate char[]mSmallCBuffer
-
Constructor Summary
Constructors Constructor Description BufferRecycler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getFullBBuffer(int minSize)char[]getFullCBuffer(int minSize)char[]getMediumCBuffer(int minSize)char[]getSmallCBuffer(int minSize)voidreturnFullBBuffer(byte[] buffer)voidreturnFullCBuffer(char[] buffer)voidreturnMediumCBuffer(char[] buffer)voidreturnSmallCBuffer(char[] buffer)
-
-
-
Method Detail
-
getSmallCBuffer
public char[] getSmallCBuffer(int minSize)
-
returnSmallCBuffer
public void returnSmallCBuffer(char[] buffer)
-
getMediumCBuffer
public char[] getMediumCBuffer(int minSize)
-
returnMediumCBuffer
public void returnMediumCBuffer(char[] buffer)
-
getFullCBuffer
public char[] getFullCBuffer(int minSize)
-
returnFullCBuffer
public void returnFullCBuffer(char[] buffer)
-
getFullBBuffer
public byte[] getFullBBuffer(int minSize)
-
returnFullBBuffer
public void returnFullBBuffer(byte[] buffer)
-
-