Class LimitedBufferSlicePool


  • public final class LimitedBufferSlicePool
    extends Object
    A limited buffer pooled allocator. This pool uses a series of buffer regions to back the returned pooled buffers. When the buffer is no longer needed, it should be freed back into the pool; failure to do so will cause the corresponding buffer area to be unavailable until the buffer is garbage-collected.
    Author:
    David M. Lloyd, Jason T. Greene
    • Constructor Detail

      • LimitedBufferSlicePool

        public LimitedBufferSlicePool​(org.xnio.BufferAllocator<ByteBuffer> allocator,
                                      int bufferSize,
                                      int maxRegionSize,
                                      int maxRegions)
        Construct a new instance.
        Parameters:
        allocator - the buffer allocator to use
        bufferSize - the size of each buffer
        maxRegionSize - the maximum region size for each backing buffer
        maxRegions - the maximum regions to create, zero for unlimited
      • LimitedBufferSlicePool

        public LimitedBufferSlicePool​(org.xnio.BufferAllocator<ByteBuffer> allocator,
                                      int bufferSize,
                                      int maxRegionSize)
        Construct a new instance.
        Parameters:
        allocator - the buffer allocator to use
        bufferSize - the size of each buffer
        maxRegionSize - the maximum region size for each backing buffer
      • LimitedBufferSlicePool

        public LimitedBufferSlicePool​(int bufferSize,
                                      int maxRegionSize)
        Construct a new instance, using a direct buffer allocator.
        Parameters:
        bufferSize - the size of each buffer
        maxRegionSize - the maximum region size for each backing buffer
    • Method Detail

      • canAllocate

        public boolean canAllocate​(int slices)