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

zmq.msg.MsgAllocatorThreshold Maven / Gradle / Ivy

There is a newer version: 0.6.0
Show newest version
package zmq.msg;

import zmq.Config;
import zmq.Msg;

public class MsgAllocatorThreshold implements MsgAllocator
{
    private static final MsgAllocator direct = new MsgAllocatorDirect();
    private static final MsgAllocator heap   = new MsgAllocatorHeap();

    public final int threshold;

    public MsgAllocatorThreshold()
    {
        this(Config.MSG_ALLOCATION_HEAP_THRESHOLD.getValue());
    }

    public MsgAllocatorThreshold(int threshold)
    {
        this.threshold = threshold;
    }

    @Override
    public Msg allocate(int size)
    {
        if (threshold > 0 && size > threshold) {
            return direct.allocate(size);
        }
        else {
            return heap.allocate(size);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy