RecyclerPool (starting with 2.16): multiple pool
implementations exists.
The default pool implementation uses
ThreadLocal combined with SoftReference.
The end result is a low-overhead GC-cleanable recycling: hopefully
ideal for use by stream readers.
Rewritten in 2.10 to be thread-safe (see [jackson-core#479] for details),
to not rely on ThreadLocal access.
Rewritten in 2.16 to work with RecyclerPool abstraction.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | BufferRecycler.
Tag-on interface to allow various other types to expose |
| Modifier and Type | Field and Description |
|---|---|
| protected final AtomicReferenceArray | |
| protected final AtomicReferenceArray | |
| private RecyclerPool | |
| public static final int | BYTE_BASE64_CODEC_BUFFER
Buffer used for concatenating binary data that is either being encoded as base64 output, or decoded from base64 input. |
| private static final int[] | |
| public static final int | BYTE_READ_IO_BUFFER
Buffer used for reading byte-based input. |
| public static final int | BYTE_WRITE_CONCAT_BUFFER
Buffer used for temporarily concatenating output; used for example when requesting output as byte array. |
| public static final int | BYTE_WRITE_ENCODING_BUFFER
Buffer used for temporarily storing encoded content; used for example by UTF-8 encoding writer |
| private static final int[] | |
| public static final int | CHAR_CONCAT_BUFFER
Buffer used by generators; for byte-backed generators for buffering of
|
| public static final int | CHAR_NAME_COPY_BUFFER
For parsers, temporary buffer into which |
| public static final int | CHAR_TEXT_BUFFER
Used through |
| public static final int | CHAR_TOKEN_BUFFER
Buffer used as input buffer for tokenization for character-based parsers. |
| Access | Constructor and Description |
|---|---|
| public | |
| protected | BufferRecycler(int
Number of bbCount, int byte[] buffers to allocateNumber of cbCount)char[] buffers to allocateAlternate constructor to be used by sub-classes, to allow customization of number of low-level buffers in use. |
| Modifier and Type | Method and Description |
|---|---|
| public final byte[] | Returns: Buffer allocated (possibly recycled)One of ix)READ_IO_BUFFER constants.
|
| public byte[] | |
| public final char[] | |
| public char[] | |
| protected byte[] | |
| protected int | |
| protected char[] | |
| protected int | |
| public boolean | Returns: True if this recycler is linked to pool and may be released withreleaseToPool(); false if no linkage exists.
|
| public void | |
| public void | |
| public void | releaseToPool()
Implements com. Method called when owner of this recycler no longer wishes use it; this should
return it to pool passed via |
| public BufferRecycler | withPool(RecyclerPool<BufferRecycler>
Pool that "owns" pooled item pool)Implements com. Method called by owner of this recycler instance, to provide reference to
|
| _byteBuffers | back to summary |
|---|---|
| protected final AtomicReferenceArray<byte[]> _byteBuffers | |
| _charBuffers | back to summary |
|---|---|
| protected final AtomicReferenceArray<char[]> _charBuffers | |
| _pool | back to summary |
|---|---|
| private RecyclerPool<BufferRecycler> _pool | |
| BYTE_BASE64_CODEC_BUFFER | back to summary |
|---|---|
| public static final int BYTE_BASE64_CODEC_BUFFER Buffer used for concatenating binary data that is either being encoded as base64 output, or decoded from base64 input.
| |
| BYTE_BUFFER_LENGTHS | back to summary |
|---|---|
| private static final int[] BYTE_BUFFER_LENGTHS | |
| BYTE_READ_IO_BUFFER | back to summary |
|---|---|
| public static final int BYTE_READ_IO_BUFFER Buffer used for reading byte-based input. | |
| BYTE_WRITE_CONCAT_BUFFER | back to summary |
|---|---|
| public static final int BYTE_WRITE_CONCAT_BUFFER Buffer used for temporarily concatenating output; used for example when requesting output as byte array. | |
| BYTE_WRITE_ENCODING_BUFFER | back to summary |
|---|---|
| public static final int BYTE_WRITE_ENCODING_BUFFER Buffer used for temporarily storing encoded content; used for example by UTF-8 encoding writer | |
| CHAR_BUFFER_LENGTHS | back to summary |
|---|---|
| private static final int[] CHAR_BUFFER_LENGTHS | |
| CHAR_CONCAT_BUFFER | back to summary |
|---|---|
| public static final int CHAR_CONCAT_BUFFER Buffer used by generators; for byte-backed generators for buffering of
| |
| CHAR_NAME_COPY_BUFFER | back to summary |
|---|---|
| public static final int CHAR_NAME_COPY_BUFFER For parsers, temporary buffer into which | |
| CHAR_TEXT_BUFFER | back to summary |
|---|---|
| public static final int CHAR_TEXT_BUFFER Used through | |
| CHAR_TOKEN_BUFFER | back to summary |
|---|---|
| public static final int CHAR_TOKEN_BUFFER Buffer used as input buffer for tokenization for character-based parsers. | |
| BufferRecycler | back to summary |
|---|---|
| public BufferRecycler() Default constructor used for creating instances of this default implementation. | |
| BufferRecycler | back to summary |
|---|---|
| protected BufferRecycler(int bbCount, int cbCount) Alternate constructor to be used by sub-classes, to allow customization of number of low-level buffers in use.
| |
| allocByteBuffer | back to summary |
|---|---|
public final byte[] allocByteBuffer(int ix)
| |
| allocByteBuffer | back to summary |
|---|---|
| public byte[] allocByteBuffer(int ix, int minSize) | |
| allocCharBuffer | back to summary |
|---|---|
| public final char[] allocCharBuffer(int ix) | |
| allocCharBuffer | back to summary |
|---|---|
| public char[] allocCharBuffer(int ix, int minSize) | |
| balloc | back to summary |
|---|---|
| protected byte[] balloc(int size) | |
| byteBufferLength | back to summary |
|---|---|
| protected int byteBufferLength(int ix) | |
| calloc | back to summary |
|---|---|
| protected char[] calloc(int size) | |
| charBufferLength | back to summary |
|---|---|
| protected int charBufferLength(int ix) | |
| isLinkedWithPool | back to summary |
|---|---|
public boolean isLinkedWithPool()
| |
| releaseByteBuffer | back to summary |
|---|---|
| public void releaseByteBuffer(int ix, byte[] buffer) | |
| releaseCharBuffer | back to summary |
|---|---|
| public void releaseCharBuffer(int ix, char[] buffer) | |
| releaseToPool | back to summary |
|---|---|
| public void releaseToPool() Implements com. Method called when owner of this recycler no longer wishes use it; this should
return it to pool passed via
| |
| withPool | back to summary |
|---|---|
| public BufferRecycler withPool(RecyclerPool<BufferRecycler> pool) Implements com. Method called by owner of this recycler instance, to provide reference to
| |
BufferRecycler
they are constructed with.
| Modifier and Type | Method and Description |
|---|---|
| public BufferRecycler | Returns: Buffer recycler instance object is configured with, if any; whether this can benull depends on type of object
|
| bufferRecycler | back to summary |
|---|---|
public BufferRecycler bufferRecycler()
| |