Esempio n. 1
0
        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");
            }
        }
Esempio n. 2
0
        public void UnlockReadTest()
        {
            MyLM        target   = new MyLM();
            Transaction context  = new Transaction();
            Transaction context2 = new Transaction();
            Lockable    resource = new RID(RID.Type.CAR, "test");

            target.LockForRead(context, resource);
            target.UnlockRead(context, resource);
            target.LockForWrite(context2, resource);
        }