@Override public <T> T getBoxValue(VBox<T> vbox) { /* * When either no one has written to this vbox or any committed writer * is not older than my version we know that this transaction (as well * as any parent) does not have a local value. In this case we read * directly from the vbox's body. */ OwnershipRecord currentOwner = vbox.inplace.orec; if (currentOwner.version > 0 && currentOwner.version <= this.number) { return readFromBody(vbox); } else { T value = getLocalValue(vbox); if (value == null) { // no local value exists return readFromBody(vbox); } // else return (value == NULL_VALUE) ? null : value; } }
public static <T extends VBoxAom<T>> T getTarget(ReadWriteTransaction trx, T ref){ /* * Check if the transaction trx is the current writer and owner of the * ref object. */ InplaceWrite<T> inplaceWrite = ref.inplace; OwnershipRecord currentOwner = inplaceWrite.orec; if (currentOwner.owner == trx) { // we are already the current writer return inplaceWrite.tempValue; } /* * We will check the standard write-set for an object that we could * have written in a previous invocation to the rwTrx.setBoxValue(). */ T value = (T) trx.boxesWritten.get(ref); if(value == null){ value = trx.readFromBody(ref).replicate(); // update the read-set trx.setBoxValue(ref, value); } /* * !!!!! Instead of trying to acquire the ownership over the ref object on every * put operation to the same object, as happens in the standard JVSTM, we * will just try it on the first write to an object. * !!!!! On the next put invocations we will write into the replica stored in the * standard write-set. We could take a different approach and invoke again the * trx.setBoxValue, but this option has overheads when it fails to acquire the * ownership and it will insert again the same replica into the standard write-set. */ return value; }