示例#1
0
        internal bool Clean()
        {
            if (WriteMap != null)
            {
                WriteMap.Clean();
                WriteMap = null;
            }

            return(true);

            /*
             * var toClean = Interlocked.Exchange(ref WriteMap, null);
             * // the toClean may be null because more
             * // than one thread may race into this method
             * // yet, because of the atomic getAndSet above,
             * // only one will actually clean the bodies
             * if (toClean != null)
             * {
             *  toClean.Clean();
             *  return true;
             * }
             * else
             * {
             *  return false;
             * }*/
        }
示例#2
0
 public void Merge(WriteMap other)
 {
     foreach (var kvpair in other)
     {
         Add(kvpair.Key, kvpair.Value);
     }
 }
示例#3
0
 public WriteMap(WriteMap other)
 {
     foreach (var item in other)
     {
         Add(item.Key, item.Value);
     }
 }
示例#4
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>();
 }
示例#5
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>();
 }
示例#6
0
        public bool CommitLockFree()
        {
            if (WriteMap.Count == 0)
            {
                Status = TransactionStatus.Committed;
                TxnContext.LocalContext.OldestRequiredRecord = null;
                //_txnRecord.FinishTransaction();
                return(true);
            }

            if (IsNested)
            {
                Parent.ReadMap.Merge(ReadMap);
                Parent.WriteMap.Merge(WriteMap);
                Status = TransactionStatus.Committed;
                return(true);
            }

            try
            {
                WriteMap.PrepareCommit();
                ValidateCommitAndEnqueue();
                EnsureCommitStatus();
                Status = TransactionStatus.Committed;
                TxnContext.LocalContext.OldestRequiredRecord = null;

                //_txnRecord.FinishTransaction();
                //Interlocked.Decrement(ref _commitTxnRecord.Running);

                return(true);
            }
            catch (STMCommitException)
            {
                return(false);
            }
        }
示例#7
0
 internal ActiveTxnRecord(int txNumber, WriteMap bodies)
 {
     TxNumber = txNumber;
     WriteMap = bodies;
     Running  = 1;
 }