@Override public void abortTx() { commitTx(true); //throw new Error("An Inevitable transaction cannot abort. I've committed it instead."); }
@Override protected void tryCommit() { ActiveTransactionsRecord commitRecord = getCommitTxRecord(); // we know we're valid and we're already enqueued. just set the writeset ((InevitableActiveTransactionsRecord)commitRecord).setWriteSet(makeWriteSet()); helpCommit(commitRecord); upgradeTx(commitRecord); }
@Override public void start() { ActiveTransactionsRecord latestRecord = this.activeTxRecord; // start by enqueueing the request do { latestRecord = findLatestRecord(latestRecord); setCommitTxRecord(new InevitableActiveTransactionsRecord(latestRecord.transactionNumber + 1)); } while (!latestRecord.trySetNext(getCommitTxRecord())); ensureCommitStatus(); upgradeTx(latestRecord); // once we get here, we may already increment the transaction number. // This is also required to allow setBoxValue to immediately write to // the vbox.body setNumber(getCommitTxRecord().transactionNumber); super.start(); }
@Override protected void ensureCommitStatus() { ActiveTransactionsRecord recordToCommit = Transaction.mostRecentCommittedRecord.getNext(); while ((recordToCommit != null) && (recordToCommit.transactionNumber < getCommitTxRecord().transactionNumber)) { helpCommit(recordToCommit); recordToCommit = recordToCommit.getNext(); } }
public static Transaction beginInevitable() { Transaction parent = current.get(); if (parent != null) { throw new Error("Inevitable transactions cannot be nested"); } ActiveTransactionsRecord activeRecord = getRecordForNewTransaction(); Transaction tx = new InevitableTransaction(activeRecord); tx.start(); return tx; }