com.fasterxml.jackson.dataformat.smile.SmileBufferRecycler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-dataformat-smile Show documentation
Show all versions of jackson-dataformat-smile Show documentation
Support for reading and writing Smile ("binary JSON")
encoded data using Jackson abstractions (streaming API, data binding,
tree model)
package com.fasterxml.jackson.dataformat.smile;
import java.util.concurrent.atomic.AtomicReference;
/**
* Simple helper class used for implementing simple reuse system for Smile-specific
* buffers that are used.
*
* @param Type of name entries stored in arrays to recycle
*/
public class SmileBufferRecycler
{
public final static int DEFAULT_NAME_BUFFER_LENGTH = 64;
public final static int DEFAULT_STRING_VALUE_BUFFER_LENGTH = 64;
protected AtomicReference _seenNamesBuffer = new AtomicReference<>();
protected AtomicReference _seenStringValuesBuffer = new AtomicReference<>();
public SmileBufferRecycler() { }
public T[] allocSeenNamesBuffer()
{
return _seenNamesBuffer.getAndSet(null);
}
public T[] allocSeenStringValuesBuffer()
{
return _seenStringValuesBuffer.getAndSet(null);
}
public void releaseSeenNamesBuffer(T[] buffer) {
_seenNamesBuffer.set(buffer);
}
public void releaseSeenStringValuesBuffer(T[] buffer) {
_seenStringValuesBuffer.set(buffer);
}
}