public void SetAndGetOriginalValue() { IObject obj = new BaseObject(null, new object[] { 1, 2, 3 }); TransactionalValue tvalue = new TransactionalValue(this.trobj, 2); Assert.AreEqual(3, tvalue.GetValue(this.CreateTransaction())); Assert.AreEqual(3, tvalue.GetValue(0)); }
public void RaiseIfTwoTransactionChangeTheSameSlot() { IObject obj = new BaseObject(null, new object[] { 1, 2, 3 }); TransactionalValue tvalue = new TransactionalValue(this.trobj, 0); Transaction transaction1 = this.CreateTransaction(); tvalue.SetValue(transaction1, 2); Transaction transaction2 = this.CreateTransaction(); tvalue.SetValue(transaction2, 3); }
public void RaiseIfTransactionChangeACommittedSlot() { IObject obj = new BaseObject(null, new object[] { 1, 2, 3 }); TransactionalValue tvalue = new TransactionalValue(this.trobj, 0); Transaction transaction1 = this.CreateTransaction(); Transaction transaction2 = this.CreateTransaction(); tvalue.SetValue(transaction2, 3); transaction2.Commit(this.manager.Time + 1); ////tvalue.CommitValue(transaction2); tvalue.SetValue(transaction1, 2); }
public void TwoSerializedTransactions() { IObject obj = new BaseObject(null, new object[] { 1, 2, 3 }); TransactionalValue tvalue = new TransactionalValue(this.trobj, 0); Transaction transaction1 = this.CreateTransaction(); tvalue.SetValue(transaction1, 2); tvalue.CommitValue(transaction1); Assert.AreEqual(2, tvalue.GetValue(0)); Transaction transaction2 = this.CreateTransaction(); tvalue.SetValue(transaction2, 3); tvalue.CommitValue(transaction2); Assert.AreEqual(3, tvalue.GetValue(0)); }
// TODO Review: it's only called with thread local TransactionManager.Current, no lock is needed public void RegisterValue(TransactionalValue value) { if (this.values.Contains(value)) return; this.values.Add(value); }
public object this[int n] { get { lock (this) { if (TransactionManager.CurrentTransaction == null && !this.manager.HasTransactions()) { if (this.values.Count > 0) this.ReleaseValues(); return this.inner[n]; } if (this.values.ContainsKey(n)) { if (TransactionManager.CurrentTransaction == null) return this.values[n].GetValue(this.manager.Time); else return this.values[n].GetValue(TransactionManager.CurrentTransaction); } return this.inner[n]; } } set { lock (this) { if (TransactionManager.CurrentTransaction == null && !this.manager.HasTransactions()) { if (this.values.Count > 0) this.ReleaseValues(); this.inner[n] = value; return; } if (!this.values.ContainsKey(n)) { TransactionalValue tv = new TransactionalValue(this, n); this.values[n] = tv; } if (TransactionManager.CurrentTransaction == null) this.values[n].SetValue(this.manager.Time, value); else this.values[n].SetValue(TransactionManager.CurrentTransaction, value); } } }