aeron-client/src/main/java/io/aeron/Image.java
public int blockPoll(final BlockHandler handler, final int blockLengthLimit)
    {
        if (isClosed)
        {
            return 0;
        }

        final long position = subscriberPosition.get();
        final int termOffset = (int)position & termLengthMask;
        final UnsafeBuffer termBuffer = activeTermBuffer(position);
        final int limitOffset = Math.min(termOffset + blockLengthLimit, termBuffer.capacity());
        final int resultingOffset = TermBlockScanner.scan(termBuffer, termOffset, limitOffset);
        final int length = resultingOffset - termOffset;

        if (resultingOffset > termOffset)
        {
            try
            {
                final int termId = termBuffer.getInt(termOffset + TERM_ID_FIELD_OFFSET, LITTLE_ENDIAN);
                handler.onBlock(termBuffer, termOffset, length, sessionId, termId);
            }
            catch (final Throwable t)
            {
                errorHandler.onError(t);
            }
            finally
            {
                subscriberPosition.setOrdered(position + length);
            }
        }

        return length;
    }
public int blockPoll(final BlockHandler handler, final int blockLengthLimit)
    {
        if (isClosed)
        {
            return 0;
        }

        final long position = subscriberPosition.get();
        final int termOffset = (int)position & termLengthMask;
        final UnsafeBuffer termBuffer = activeTermBuffer(position);
        final int limitOffset = Math.min(termOffset + blockLengthLimit, termBuffer.capacity());
        final int resultingOffset = TermBlockScanner.scan(termBuffer, termOffset, limitOffset);
        final int length = resultingOffset - termOffset;

        if (resultingOffset > termOffset)
        {
            try
            {
                final int termId = termBuffer.getInt(termOffset + TERM_ID_FIELD_OFFSET, LITTLE_ENDIAN);
                handler.onBlock(termBuffer, termOffset, length, sessionId, termId);
            }
            catch (final Throwable t)
            {
                errorHandler.onError(t);
            }
            finally
            {
                subscriberPosition.setOrdered(position + length);
            }
        }

        return length;
    }
Poll for new messages in a stream. If new messages are found beyond the last consumed position then they
will be delivered to the {@link BlockHandler} up to a limited number of bytes.
<p>
A scan will terminate if a padding frame is encountered. If first frame in a scan is padding then a block
for the padding is notified. If the padding comes after the first frame in a scan then the scan terminates
at the offset the padding frame begins. Padding frames are delivered singularly in a block.
<p>
Padding frames may be for a greater range than the limit offset but only the header needs to be valid so
relevant length of the frame is {@link io.aeron.protocol.DataHeaderFlyweight#HEADER_LENGTH}.

@param handler          to which block is delivered.
@param blockLengthLimit up to which a block may be in length.
@return the number of bytes that have been consumed.