public override bool IsLocked()
 {
     lock (this)
     {
         return(@lock.IsLocked());
     }
 }
 public override bool IsLocked()
 {
     lock (this)
     {
         return(lock_Renamed.IsLocked());
     }
 }
示例#3
0
 public override bool IsLocked()
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         return(@lock.IsLocked());
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
示例#4
0
        public virtual void  TestNativeFSLockFactory()
        {
            NativeFSLockFactory f = new NativeFSLockFactory(SupportClass.AppSettings.Get("tempDir", System.IO.Path.GetTempPath()));

            f.SetLockPrefix("test");
            Lock l  = f.MakeLock("commit");
            Lock l2 = f.MakeLock("commit");

            Assert.IsTrue(l.Obtain(), "failed to obtain lock");
            Assert.IsTrue(!l2.Obtain(), "succeeded in obtaining lock twice");
            l.Release();

            Assert.IsTrue(l2.Obtain(), "failed to obtain 2nd lock after first one was freed");
            l2.Release();

            // Make sure we can obtain first one again, test isLocked():
            Assert.IsTrue(l.Obtain(), "failed to obtain lock");
            Assert.IsTrue(l.IsLocked());
            Assert.IsTrue(l2.IsLocked());
            l.Release();
            Assert.IsFalse(l.IsLocked());
            Assert.IsFalse(l2.IsLocked());
        }