@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(); } } }
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); }
private void addWriteAccess0(WriteFieldAccess write) { // Add to write set writeSet.put(write); }