示例#1
0
        public object GetValue(Transaction transaction)
        {
            if (this.transaction != null && this.transaction == transaction)
                return this.value;

            return this.GetValue(transaction.Start - 1);
        }
示例#2
0
 public void RollbackValue(Transaction transaction)
 {
     lock (this.trobj)
     {
         if (this.transaction != transaction)
             return;
         this.transaction = null;
         this.value = null;
     }
 }
示例#3
0
        public void CommitTransaction()
        {
            lock (this)
                this.transactions.Remove(current);

            long trtime = Interlocked.Increment(ref this.time);
            Interlocked.Increment(ref this.time);
            current.Commit(trtime);

            current = null;
        }
示例#4
0
        public void BeginTransaction()
        {
            if (current != null)
                throw new InvalidOperationException("A Transaction is active");

            Transaction transaction = this.CreateTransaction();
            current = transaction;

            lock (this)
                this.transactions.Add(current);
        }
示例#5
0
        public void CommitValue(Transaction transaction)
        {
            lock (this.trobj)
            {
                if (this.transaction == transaction)
                {
                    this.SetValue(transaction.End, this.value);
                    this.transaction = null;
                    this.value = null;
                }

                if (this.trobj.TransactionManager.HasTransactions())
                    this.ReleaseValues(this.trobj.TransactionManager.MinimalTransactionalTime);
            }
        }
示例#6
0
        public void SetValue(Transaction transaction, object value)
        {
            if (this.transaction != null && this.transaction != transaction)
                throw new InvalidOperationException("Another transaction modified this value");

            foreach (long time in this.committedValues.Keys)
                if (time > transaction.Start)
                    throw new InvalidOperationException("Another transaction modified this value");

            if (this.transaction == null)
                transaction.RegisterValue(this);

            this.transaction = transaction;
            this.value = value;
        }