Class AbstractNIOAsyncQueueReader

    • Field Detail

      • defaultBufferSize

        protected int defaultBufferSize
    • Constructor Detail

      • AbstractNIOAsyncQueueReader

        public AbstractNIOAsyncQueueReader​(NIOTransport transport)
    • Method Detail

      • read

        public void read​(Connection<java.net.SocketAddress> connection,
                         Buffer buffer,
                         CompletionHandler<ReadResult<Buffer,​java.net.SocketAddress>> completionHandler,
                         Interceptor<ReadResult> interceptor)
        Method reads data to the buffer.
        Specified by:
        read in interface Reader<java.net.SocketAddress>
        Parameters:
        connection - the Connection to read from
        buffer - the Buffer to which data will be read
        completionHandler - CompletionHandler, which will get notified, when read will be completed
        interceptor - Interceptor, which will be able to intercept control each time new portion of a data was read to a buffer. The interceptor can decide, whether asynchronous read is completed or not, or provide other processing instructions.
      • isReady

        public final boolean isReady​(Connection connection)
        Checks whether there is ready data in AsyncQueue, associated with the Connection.
        Specified by:
        isReady in interface AsyncQueue
        Parameters:
        connection - Connection
        Returns:
        true, if there is ready data, or false otherwise.
      • onClose

        public void onClose​(Connection connection)
        Callback method, which is called, when Connection has been closed, to let processor release a connection associated resources.
        Specified by:
        onClose in interface AsyncQueue
        Parameters:
        connection - Connection
      • close

        public final void close()
        Close AsyncQueueProcessor and release associated resources
        Specified by:
        close in interface AsyncQueue
      • doRead

        protected final int doRead​(Connection connection,
                                   AsyncReadQueueRecord queueRecord)
                            throws java.io.IOException
        Performs real read on the NIO channel
        Parameters:
        connection - the Connection to read from
        queueRecord - the record to be read to
        Throws:
        java.io.IOException
      • read0

        protected abstract int read0​(Connection connection,
                                     Buffer buffer,
                                     ReadResult<Buffer,​java.net.SocketAddress> currentResult)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • onReadyToRead

        protected abstract void onReadyToRead​(Connection connection)
                                       throws java.io.IOException
        Throws:
        java.io.IOException