Class ByteArrayPool

  • All Implemented Interfaces:
    ByteArrayFactory

    public class ByteArrayPool
    extends java.lang.Object
    implements ByteArrayFactory
    Creates ByteArrays, using a pool to reduce allocation where possible. WARNING: This code has never been run!
    • Field Detail

      • freed

        private boolean freed
      • direct

        private final boolean direct
      • freeBufferCount

        private int freeBufferCount
      • freeMemory

        private long freeMemory
      • maxFreeBuffers

        private final int maxFreeBuffers
      • maxFreeMemory

        private final int maxFreeMemory
    • Constructor Detail

      • ByteArrayPool

        public ByteArrayPool​(boolean direct,
                             int maxFreeBuffers,
                             int maxFreeMemory)
        Creates a new instance of ByteArrayPool.
        Parameters:
        direct - If we should use direct buffers
        maxFreeBuffers - The maximum number of free buffers
        maxFreeMemory - The maximum amount of free memory allowed
    • Method Detail

      • create

        public ByteArray create​(int size)
        Creates a new instance of a ByteArray
        Specified by:
        create in interface ByteArrayFactory
        Parameters:
        size - The size of the array to build
        Returns:
        The ByteArray
      • bits

        private int bits​(int index)
      • free

        public void free()
        Frees the buffers