예제 #1
0
  /**
   * Tests if a the sequence number associated with a particular block location has not changed.
   *
   * @param x the x coordinate
   * @param y the y coordinate
   * @param z the z coordinate
   * @param expected the expected sequence number
   * @return true if the sequence number has not changed and expected is not
   *     DatatableSequenceNumber.ATOMIC
   */
  public final boolean testSequence(int x, int y, int z, int expected) {

    if (expected == DatatableSequenceNumber.ATOMIC) {
      return false;
    }

    checkCompressing();
    int index = getIndex(x, y, z);
    int spins = 0;
    boolean interrupted = false;
    try {
      if (spins++ > SPINS) {
        interrupted |= atomicWait();
      }
      checkCompressing();

      int blockId = blockIds.get(index);
      return auxStore.isReserved(blockId) && auxStore.testSequence(blockId, expected);
    } finally {
      if (interrupted) {
        Thread.currentThread().interrupt();
      }
    }
  }