public void LockConversionTest1() { MyLM target = new MyLM(); target.setDeadlockTimeout(1000); Transaction context = new Transaction(); Lockable resource = new RID(RID.Type.CAR, "test"); target.LockForUpdate(context, resource); target.LockForWrite(context, resource); }
public void LockConversionTest2() { MyLM target = new MyLM(); target.setDeadlockTimeout(1000); Transaction context = new Transaction(); Transaction context2 = new Transaction(); Lockable resource = new RID(RID.Type.CAR, "test"); target.setDeadlockTimeout(10); target.LockForUpdate(context, resource); target.LockForRead(context2, resource); target.LockForWrite(context, resource); Assert.Fail("shall not reach this line"); }
public void LockConversionTest3() { MyLM target = new MyLM(); target.setDeadlockTimeout(1000); Transaction context = new Transaction(); Transaction context2 = new Transaction(); Lockable resource = new RID(RID.Type.CAR, "test"); target.LockForUpdate(context, resource); target.LockForRead(context2, resource); ManualResetEvent e = new ManualResetEvent(false); ThreadPool.QueueUserWorkItem((obj) => { Thread.Sleep(200); target.UnlockRead(context2, resource); e.Set(); }); target.LockForWrite(context, resource); if (!e.WaitOne(2000)) { Assert.Fail("Failed"); } }