public final class BufferRecycler extends Object
ThreadLocal
member of the owning class pointing to
instance of this class through a SoftReference
. 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 (wouldn't it be neat 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.
Constructor and Description |
---|
BufferRecycler() |
Modifier and Type | Method and Description |
---|---|
byte[] |
getFullBBuffer(int minSize) |
char[] |
getFullCBuffer(int minSize) |
char[] |
getMediumCBuffer(int minSize) |
char[] |
getSmallCBuffer(int minSize) |
void |
returnFullBBuffer(byte[] buffer) |
void |
returnFullCBuffer(char[] buffer) |
void |
returnMediumCBuffer(char[] buffer) |
void |
returnSmallCBuffer(char[] buffer) |
public char[] getSmallCBuffer(int minSize)
public void returnSmallCBuffer(char[] buffer)
public char[] getMediumCBuffer(int minSize)
public void returnMediumCBuffer(char[] buffer)
public char[] getFullCBuffer(int minSize)
public void returnFullCBuffer(char[] buffer)
public byte[] getFullBBuffer(int minSize)
public void returnFullBBuffer(byte[] buffer)
Copyright © 2018 FasterXML. All rights reserved.