Class AsyncStreamingInputPlus

    • Constructor Detail

      • AsyncStreamingInputPlus

        public AsyncStreamingInputPlus​(io.netty.channel.Channel channel)
    • Method Detail

      • append

        public boolean append​(io.netty.buffer.ByteBuf buf)
                       throws java.lang.IllegalStateException
        Append a ByteBuf to the end of the einternal queue. Note: it's expected this method is invoked on the netty event loop.
        Throws:
        java.lang.IllegalStateException
      • reBuffer

        protected void reBuffer()
                         throws java.io.EOFException,
                                AsyncStreamingInputPlus.InputTimeoutException
        Implementations must implement this method to refill the buffer. They can expect the buffer to be empty when this method is invoked. Release open buffers and poll the queue for more data.

        This is best, and more or less expected, to be invoked on a consuming thread (not the event loop) becasue if we block on the queue we can't fill it on the event loop (as that's where the buffers are coming from).

        Specified by:
        reBuffer in class RebufferingInputStream
        Throws:
        java.io.EOFException - when no further reading from this instance should occur. Implies this instance is closed.
        AsyncStreamingInputPlus.InputTimeoutException - when no new buffers arrive for reading before the rebufferTimeoutNanos elapses while blocking. It's then not safe to reuse this instance again.
      • consume

        public void consume​(AsyncStreamingInputPlus.Consumer consumer,
                            long length)
                     throws java.io.IOException
        Consumes bytes in the stream until the given length
        Throws:
        java.io.IOException
      • unsafeAvailable

        public int unsafeAvailable()
        As long as this method is invoked on the consuming thread the returned value will be accurate.
      • maybeIssueRead

        public void maybeIssueRead()
      • isEmpty

        public boolean isEmpty()
      • close

        public void close()
        Note: This should invoked on the consuming thread.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
      • requestClosure

        public void requestClosure()
        Mark this stream as closed, but do not release any of the resources. Note: this is best to be called from the producer thread.
      • getAllocator

        public io.netty.buffer.ByteBufAllocator getAllocator()