Example #1
0
  @Override
  public boolean commit() {
    try {
      if (writeSet.isEmpty()) // if the writeSet is empty no need to lock a thing.
      return true;

      try {
        // pre commit validation phase
        writeSet.forEach(lockProcedure);
        readSet.checkClock(localClock);
      } catch (TransactionException exception) {
        lockProcedure.unlockAll();
        return false;
      }

      // commit new values and release locks
      writeSet.forEach(putProcedure);
      lockProcedure.setAndUnlockAll();
      return true;
    } finally {
      if (irrevocableState) {
        irrevocableState = false;
        irrevocableAccessLock.writeLock().unlock();
      } else {
        irrevocableAccessLock.readLock().unlock();
      }
    }
  }
Example #2
0
  private WriteFieldAccess onReadAccess0(Object obj, long field, int advice) {

    ReadFieldAccess current = currentReadFieldAccess;
    int hash = current.hashCode();

    // Check the read is still valid
    LockTable.checkLock(hash, localClock, lastReadLock);

    // Check if it is already included in the write set
    return writeSet.contains(current);
  }
Example #3
0
  private void addWriteAccess0(WriteFieldAccess write) {

    // Add to write set
    writeSet.put(write);
  }