All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.jackson.dataformat.smile.SmileBufferRecycler Maven / Gradle / Ivy

Go to download

Support for reading and writing Smile ("binary JSON") encoded data using Jackson abstractions (streaming API, data binding, tree model)

There is a newer version: 2.18.1
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy