Top Description Fields Constructors Methods
com.fasterxml.aalto.util

public final Class BufferRecycler

extends Object
Class Inheritance

This is a small utility class, whose main functionality is to allow simple reuse of raw byte/char buffers. It is usually used through 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 (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

Modifier and TypeField and Description
private volatile byte[]
private volatile char[]
private volatile char[]
private volatile char[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

public synchronized char[]
getFullCBuffer(int minSize)

public synchronized char[]
getMediumCBuffer(int minSize)

public synchronized char[]
getSmallCBuffer(int minSize)

public synchronized void
returnFullBBuffer(byte[] buffer)

public synchronized void
returnFullCBuffer(char[] buffer)

public synchronized void
returnMediumCBuffer(char[] buffer)

public synchronized void
returnSmallCBuffer(char[] buffer)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mFullBBufferback to summary
private volatile byte[] mFullBBuffer
mFullCBufferback to summary
private volatile char[] mFullCBuffer
mMediumCBufferback to summary
private volatile char[] mMediumCBuffer
mSmallCBufferback to summary
private volatile char[] mSmallCBuffer

Constructor Detail

BufferRecyclerback to summary
public BufferRecycler()

Method Detail

getFullBBufferback to summary
public synchronized byte[] getFullBBuffer(int minSize)
getFullCBufferback to summary
public synchronized char[] getFullCBuffer(int minSize)
getMediumCBufferback to summary
public synchronized char[] getMediumCBuffer(int minSize)
getSmallCBufferback to summary
public synchronized char[] getSmallCBuffer(int minSize)
returnFullBBufferback to summary
public synchronized void returnFullBBuffer(byte[] buffer)
returnFullCBufferback to summary
public synchronized void returnFullCBuffer(char[] buffer)
returnMediumCBufferback to summary
public synchronized void returnMediumCBuffer(char[] buffer)
returnSmallCBufferback to summary
public synchronized void returnSmallCBuffer(char[] buffer)