Interface StreamBufferPool<B>

    • Method Detail

      • getUnpooledStreamBuffer

        StreamBuffer<B> getUnpooledStreamBuffer​(java.nio.ByteBuffer buffer)

        Obtains an StreamBuffer that is not pooled. This is for ByteBuffer instances that are managed outside the BufferPool.

        Typical use is to create StreamBuffer for some read-only cached content within a ByteBuffer.

        Parameters:
        buffer - ByteBuffer.
        Returns:
        StreamBuffer for the unpooled ByteBuffer.
      • getFileStreamBuffer

        StreamBuffer<B> getFileStreamBuffer​(java.nio.channels.FileChannel file,
                                            long position,
                                            long count,
                                            FileCompleteCallback callback)
                                     throws java.io.IOException

        Obtains a StreamBuffer for the FileChannel content.

        This enables efficient writing (ie DMA) of FileChannel content.

        To write the entire FileChannel contents, invoke write(file, 0, -1).

        Note that the underlying implementation will need to support FileChannel efficiencies.

        Parameters:
        file - FileChannel.
        position - Position within the FileChannel to start writing content. Must be non-negative number.
        count - Count of bytes to write from the FileChannel. A negative value (typically -1) indicates to write the remaining FileChannel content from the position.
        callback - Optional FileCompleteCallback. May be null.
        Returns:
        StreamBuffer for the FileChannel.
        Throws:
        java.io.IOException - If fails to create the StreamBuffer for the FileChannel. Typically, this is because the underlying implementation does not support DMA and copies the data from the FileChannel.
      • close

        void close()
        Closes pool releasing all StreamBuffer instances.
        Specified by:
        close in interface java.lang.AutoCloseable