Example #1
0
 private JVTransaction(TransactionStatus status, int id, JVTransaction parent, ReadMap readMap, WriteMap writeMap)
 {
     Number   = id;
     Parent   = parent;
     ReadMap  = readMap;
     WriteMap = writeMap;
     Status   = status;
     //Commutes = new List<BaseCommute>();
 }
Example #2
0
 private JVTransaction(TransactionStatus status, ActiveTxnRecord txnRecord, JVTransaction parent, ReadMap readMap, WriteMap writeMap)
 {
     Number     = txnRecord.TxNumber;
     Parent     = parent;
     ReadMap    = readMap;
     WriteMap   = writeMap;
     Status     = status;
     _txnRecord = txnRecord;
     //Commutes = new List<BaseCommute>();
 }
Example #3
0
        public T Read(JVTransaction transaction)
        {
            if (transaction.WriteMap.ContainsKey(this))
            {
                return((T)transaction.WriteMap[this]);
            }

            var body    = _body;
            var tNumber = transaction.Number;

            while (body.Version > tNumber)
            {
                body = body.Next;
            }

            transaction.ReadMap.Put(this, body);

            return(body.Value);
        }
Example #4
0
        private static int HandleRetry <T>(IList <Func <JVTransaction, T> > stmActions, JVTransaction transaction, int index, ReadMap overAllReadSet)
        {
            if (stmActions.Count == 1) //Optimized for when there are no orelse blocks
            {
                WaitOnReadset(transaction, transaction.ReadMap);
            }
            else if (stmActions.Count == index + 1) //Final orelse block
            {
                overAllReadSet.Merge(transaction.ReadMap);
                WaitOnReadset(transaction, overAllReadSet);
                index = 0;
            }
            else //Non final atomic or orelse blocks
            {
#if DEBUG
                Console.WriteLine("Transaction: " + transaction.Number + " ORELSE jump");
#endif
                overAllReadSet.Merge(transaction.ReadMap);
                index++;
            }

            return(index);
        }
Example #5
0
 public void Put(JVTransaction transaction, T value)
 {
     transaction.WriteMap.Add(this, value);
 }
Example #6
0
 public void Commute(JVTransaction transaction, Func <T, T> action)
 {
     transaction.Commutes.Add(new Commute <T>(action, this));
 }
Example #7
0
 public static JVTransaction StartNested(JVTransaction parent)
 {
     return(new JVTransaction(TransactionStatus.Active, parent.Number, parent, new ReadMap(), new WriteMap(parent.WriteMap)));
 }