List<? super PollStreamEvent> result,
int maxEvents, byte[] stateContent) throws IOException {
Iterator<? extends StreamEventOffset> iterator = Iterators.consumingIterator(source.iterator());
int eventsClaimed = 0;
while (result.size() < maxEvents && iterator.hasNext()) {
StreamEventOffset event = iterator.next();
byte[] stateRow = claimEntry(event.getOffset(), stateContent);
if (stateRow == null) {
continue;
}
result.add(new PollStreamEvent(event, stateRow));
eventsClaimed++;