public boolean next() throws EOFException {
  if (limit >= fileSize) {
    throw new EOFException("End of file was reached");
  }
  if (mem.getLongVolatile(Structure.Limit) <= limit) {
    return false;
  }
  byte commit=mem.getByteVolatile(limit);
  byte rollback=mem.getByteVolatile(limit + Length.Commit);
  if (rollback == Rollback.Set) {
    limit+=Length.RecordHeader + recordSize;
    timeoutCounter=0;
    timerStart=0;
    return false;
  }
  if (commit == Commit.Set) {
    timeoutCounter=0;
    timerStart=0;
    return true;
  }
  timeoutCounter++;
  if (timeoutCounter >= MAX_TIMEOUT_COUNT) {
    if (timerStart == 0) {
      timerStart=System.currentTimeMillis();
    }
 else {
      if (System.currentTimeMillis() - timerStart >= maxTimeout) {
        mem.putByteVolatile(limit + Length.Commit,Rollback.Set);
        limit+=Length.RecordHeader + recordSize;
        timeoutCounter=0;
        timerStart=0;
        return false;
      }
    }
  }
  return false;
}

public boolean next ( ) throws EOFException { if ( limit >= fileSize ) { throw new EOFException ( "End of file was reached" ) ; } if ( mem . getLongVolatile ( Structure . Limit ) <= limit ) { return false ; } byte commit = mem . getByteVolatile ( limit ) ; byte rollback = mem . getByteVolatile ( limit + Length . Commit ) ; if ( rollback == Rollback . Set ) { limit += Length . RecordHeader + recordSize ; timeoutCounter = 0 ; timerStart = 0 ; return false ; } if ( commit == Commit . Set ) { timeoutCounter = 0 ; timerStart = 0 ; return true ; } timeoutCounter ++ ; if ( timeoutCounter >= MAX_TIMEOUT_COUNT ) { if ( timerStart == 0 ) { timerStart = System . currentTimeMillis ( ) ; } else { if ( System . currentTimeMillis ( ) - timerStart >= maxTimeout ) { mem . putByteVolatile ( limit + Length . Commit , Rollback . Set ) ; limit += Length . RecordHeader + recordSize ; timeoutCounter = 0 ; timerStart = 0 ; return false ; } } } return false ; }
steps forward to the next record if there ' s one available . the method has a timeout for how long it will wait for the commit field to be set . when the timeout is reached it will set the roll back field and skip over the record .
