private void execute(ReadOperation op, int length) {
    checkReadable(length);

    if (!buffers.isEmpty()) {
      advanceBufferIfNecessary();
    }

    for (; length > 0 && !buffers.isEmpty(); advanceBufferIfNecessary()) {
      ReadableBuffer buffer = buffers.peek();
      int lengthToCopy = Math.min(length, buffer.readableBytes());

      // Perform the read operation for this buffer.
      op.read(buffer, lengthToCopy);
      if (op.isError()) {
        return;
      }

      length -= lengthToCopy;
      readableBytes -= lengthToCopy;
    }

    if (length > 0) {
      // Should never get here.
      throw new AssertionError("Failed executing read operation");
    }
  }
private void execute ( ReadOperation op , int length ) { checkReadable ( length ) ; if ( ! buffers . isEmpty ( ) ) { advanceBufferIfNecessary ( ) ; } for ( ; length > 0 && ! buffers . isEmpty ( ) ; advanceBufferIfNecessary ( ) ) { ReadableBuffer buffer = buffers . peek ( ) ; int lengthToCopy = Math . min ( length , buffer . readableBytes ( ) ) ; op . read ( buffer , lengthToCopy ) ; if ( op . isError ( ) ) { return ; } length -= lengthToCopy ; readableBytes -= lengthToCopy ; } if ( length > 0 ) { throw new AssertionError ( "Failed executing read operation" ) ; } }
Executes the given {@link ReadOperation} against the {@link ReadableBuffer}s required to
satisfy the requested {@code length}.