protected void initializeTransactionFactory() { jvstm.Transaction.setTransactionFactory(new jvstm.TransactionFactory() { @Override public jvstm.Transaction makeTopLevelTransaction(jvstm.ActiveTransactionsRecord record) { return new NonPersistentTopLevelTransaction(record); } @Override public jvstm.Transaction makeReadOnlyTopLevelTransaction(jvstm.ActiveTransactionsRecord record) { return new NonPersistentTopLevelReadOnlyTransaction(record); } }); }
private static <T extends VBoxAom<T>> void putInInevitableTrx(T ref, byte newValue, long fieldOffset){ Transaction tx = Transaction.beginInevitable(); T newT = getTargetForInnevitable(ref, tx.number); UtilUnsafe.UNSAFE.putByte(newT, fieldOffset, newValue); tx.setBoxValue(ref, newT); tx.commit(); }
public void put(E newE) { Transaction tx = Transaction.current(); if (tx == null) { tx = Transaction.beginInevitable(); tx.setBoxValue(this, newE); tx.commit(); } else { tx.setBoxValue(this, newE); } }
public void put(E newE) { Transaction tx = Transaction.current(); if (tx == null) { tx = Transaction.begin(); tx.setPerTxValue(this, newE); tx.commit(); } else { tx.setPerTxValue(this, newE); } }
public E get() { Transaction tx = Transaction.current(); if (tx == null) { tx = Transaction.begin(); E result = tx.getPerTxValue(this, initial); tx.commit(); return result; } else { return tx.getPerTxValue(this, initial); } }
@SuppressWarnings("static-access") public void put(int index, E newE) { rangeCheck(index); Transaction tx = Transaction.current(); if (tx == null) { tx = Transaction.begin(); tx.setArrayValue(new VArrayEntry<E>(this, index), newE); tx.commit(); } else { tx.setArrayValue(new VArrayEntry<E>(this, index), newE); } }
@SuppressWarnings("static-access") public E get(int index) { rangeCheck(index); // TODO: Apply the same optimization as in VBox.get() Transaction tx = Transaction.current(); if (tx == null) { tx = Transaction.begin(true); E value = tx.getArrayValue(new VArrayEntry<E>(this, index)); tx.commit(); return value; } else { return tx.getArrayValue(new VArrayEntry<E>(this, index)); } }
public static FenixTransaction currentFenixTransaction() { return (FenixTransaction) Transaction.current(); }
public static <T> T doIt(Callable<T> xaction, boolean tryReadOnly) throws Exception { T result = null; while (true) { Transaction.begin(tryReadOnly); boolean finished = false; try { result = xaction.call(); Transaction.commit(); finished = true; return result; } catch (CommitException ce) { Transaction.abort(); finished = true; } catch (WriteOnReadException wore) { Transaction.abort(); finished = true; tryReadOnly = false; } finally { if (! finished) { Transaction.abort(); } } } } }
@Override public final <V> V perform(Callable<V> method) throws Exception { boolean inTransaction = Transaction.isInTransaction(); if (flattenTx && inTransaction) { return method.call(); Transaction.begin(readOnly); boolean txFinished = false; try { V result = method.call(); Transaction.commit(); txFinished = true; return result; } catch (EarlyAbortException eae) { Transaction.abort(); txFinished = true; Transaction.abort(); txFinished = true; } catch (WriteOnReadException wore) { Transaction.abort(); txFinished = true; readOnly = false; } finally { if (!txFinished) { Transaction.abort();
@Override protected void backendCommit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { if (Transaction.current() != underlyingTransaction) { throw new IllegalStateException("JVSTM does not support committing transactions from other threads!"); } try { Transaction.commit(); } catch (CommitException e) { throw new JvstmCommitError(); } }
public static Transaction begin(boolean readOnly) { ActiveTransactionsRecord activeRecord = null; Transaction parent = current(); if (TRANSACTION_FACTORY.reuseTopLevelReadOnlyTransactions() && parent == null && readOnly) { Transaction tx = getRecordForNewTransaction().tx; tx.start(); return tx; } if (parent == null) { activeRecord = getRecordForNewTransaction(); } return beginWithActiveRecord(readOnly, activeRecord); }
@Override public T call() throws Exception { super.parent.start(); Transaction tx = Transaction.beginUnsafeMultithreaded(); try { T value = execute(); tx.commit(); tx = null; return value; } catch (EarlyAbortException eae) { tx.abort(); throw eae; } catch (CommitException ce) { tx.abort(); throw ce; } catch (Throwable t) { if (t instanceof Exception) { throw (Exception) t; } else { t.printStackTrace(); System.exit(0); return null; } } }
public static void setupJVSTM() { jvstm.Transaction.setTransactionFactory(new jvstm.TransactionFactory() { @Override public jvstm.Transaction makeTopLevelTransaction(jvstm.ActiveTransactionsRecord record) { return new TopLevelTransaction(record); } @Override public jvstm.Transaction makeReadOnlyTopLevelTransaction(jvstm.ActiveTransactionsRecord record) { return new ReadOnlyTopLevelTransaction(record); } }); // initialize transaction system int maxTx = TransactionChangeLogs.initializeTransactionSystem(); if (maxTx >= 0) { logger.info("Setting the last committed TX number to {}", maxTx); Transaction.setMostRecentActiveRecord(new ActiveTransactionsRecord(maxTx, null)); } else { throw new Error("Couldn't determine the last transaction number"); } }
public E get() { Transaction tx = Transaction.current(); if (tx == null) { // Access the box body without creating a full transaction, while // still preserving ordering guarantees by 'piggybacking' on the // version from the latest commited transaction. // If the box body is GC'd before we can reach it, the process // re-starts with a newer transaction. while (true) { int transactionNumber = Transaction.mostRecentCommittedRecord.transactionNumber; VBoxBody<E> boxBody = this.body; do { if (boxBody.version <= transactionNumber) { return boxBody.value; } boxBody = boxBody.next; } while (boxBody != null); } } else { return tx.getBoxValue(this); } }
@Override protected void backendCommit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { jvstm.Transaction.commit(); }