public static void Do <T>(TransactionBlock <T> block) where T : struct { IStmTransaction <T> tx = GetStmTransaction <T>(); block.SetTx(tx); bool commited = false; while (!commited) { block.Run(); tx.Commit(); commited = tx.IsCommited; if (!commited) { tx.Rollback(); } } }
private static bool WaitOtherSubtransactionsToCommit(IStmTransaction transaction) { if (transaction.ParentTransaction != null) { int countSubTransactionsCommited = 0; while (countSubTransactionsCommited != transaction.ParentTransaction.CountSubtransactions) { countSubTransactionsCommited = 1; bool wasParentConflict = false; foreach (IStmTransaction subTransaction in transaction.ParentTransaction.SubTransactions) { if (subTransaction.Number != transaction.Number) { switch (subTransaction.State) { case I_TRANSACTION_STATE.COMMITED: countSubTransactionsCommited++; break; case I_TRANSACTION_STATE.PARENT_CONFLICT: wasParentConflict = true; break; default: break; } } } if (wasParentConflict) { return(true); } } } return(false); }
public void AddSubTransaction(IStmTransaction <T> subTransaction) { subTransactionList.Add(subTransaction); }
public void SetParentTransaction(IStmTransaction <T> parentTransaction) { this.parentTransaction = parentTransaction; parentTransaction.AddSubTransaction(this); }
public void AddSubTransaction(IStmTransaction <T> subTransaction) { stmTransaction.AddSubTransaction(subTransaction); }
public void SetParentTransaction(IStmTransaction <T> parentTransaction) { stmTransaction.SetParentTransaction(parentTransaction); }
public void SetTx(IStmTransaction <T> tx) { this.tx = tx; }
public LoggingStmTransaction(IStmTransaction stmTransaction) { baseTransaction = stmTransaction; }
public void AddSubTransaction(IStmTransaction subTransaction) { baseTransaction.AddSubTransaction(subTransaction); }
public void SetParentTransaction(IStmTransaction parentTransaction) { baseTransaction.SetParentTransaction(parentTransaction); }
public void AddSubTransaction(IStmTransaction <T> subTransaction) { }
public void SetParentTransaction(IStmTransaction <T> parentTransaction) { }
public void Set(T value, IStmTransaction <T> tx) { tx.Write(this, value); }
public T Get(IStmTransaction <T> ctx) { return(ctx.Read(this)); }