Пример #1
0
 /*
  * Method to check if the writer is going to overwrite the readerPosition
  *
  * Writer is expected to be ahead of the reader.
  * Assumes the input contains the GenId (Look at the edge-case below)
  *
  */
 public static boolean containsReaderPosition(
     long writerStart, long writerEnd, long readerPosition, BufferPositionParser parser) {
   if (readerPosition < 0) return false; // empty
   // just make the reader look the same generation as the writer
   if (parser.bufferGenId(readerPosition) < parser.bufferGenId(writerStart)) {
     long fakeReaderPos = parser.setGenId(readerPosition, parser.bufferGenId(writerStart));
     return writerStart <= fakeReaderPos && fakeReaderPos < writerEnd;
   } else {
     return writerStart <= readerPosition && readerPosition < writerEnd;
   }
 }