Beispiel #1
0
        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();
                }
            }
        }
Beispiel #2
0
        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);
 }
Beispiel #5
0
 public void AddSubTransaction(IStmTransaction <T> subTransaction)
 {
     stmTransaction.AddSubTransaction(subTransaction);
 }
Beispiel #6
0
 public void SetParentTransaction(IStmTransaction <T> parentTransaction)
 {
     stmTransaction.SetParentTransaction(parentTransaction);
 }
Beispiel #7
0
 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);
 }
Beispiel #11
0
 public void AddSubTransaction(IStmTransaction <T> subTransaction)
 {
 }
Beispiel #12
0
 public void SetParentTransaction(IStmTransaction <T> parentTransaction)
 {
 }
Beispiel #13
0
 public void Set(T value, IStmTransaction <T> tx)
 {
     tx.Write(this, value);
 }
Beispiel #14
0
 public T Get(IStmTransaction <T> ctx)
 {
     return(ctx.Read(this));
 }