Class RecyclingIntBlockAllocator

  • public final class RecyclingIntBlockAllocator
    extends IntBlockPool.Allocator
    A IntBlockPool.Allocator implementation that recycles unused int blocks in a buffer and reuses them in subsequent calls to getIntBlock().

    Note: This class is not thread-safe

    NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    • Field Detail


        public static final int DEFAULT_BUFFERED_BLOCKS
        See Also:
        Constant Field Values
    • Constructor Detail

      • RecyclingIntBlockAllocator

        public RecyclingIntBlockAllocator​(int blockSize,
                                          int maxBufferedBlocks,
                                          Counter bytesUsed)
        blockSize - the block size in bytes
        maxBufferedBlocks - maximum number of buffered int block
        bytesUsed - Counter reference counting internally allocated bytes
      • RecyclingIntBlockAllocator

        public RecyclingIntBlockAllocator​(int blockSize,
                                          int maxBufferedBlocks)
        blockSize - the size of each block returned by this allocator
        maxBufferedBlocks - maximum number of buffered int blocks
    • Method Detail

      • numBufferedBlocks

        public int numBufferedBlocks()
        the number of currently buffered blocks
      • bytesUsed

        public long bytesUsed()
        the number of bytes currently allocated by this IntBlockPool.Allocator
      • maxBufferedBlocks

        public int maxBufferedBlocks()
        the maximum number of buffered byte blocks
      • freeBlocks

        public int freeBlocks​(int num)
        Removes the given number of int blocks from the buffer if possible.
        num - the number of int blocks to remove
        the number of actually removed buffers