示例#1
0
 public void DoubleWriteLockThrows()
 {
     using (ILockStrategy strategy = GetLockStrategy())
     {
         using (var writeLock1 = strategy.GetWriteLock())
         {
             using (var writeLock2 = strategy.GetWriteLock())
             {
                 //do nothing
             }
         }
     }
 }
示例#2
0
 protected void DoubleWriteLock()
 {
     using (ILockStrategy strategy = this.GetLockStrategy())
     {
         using (var writeLock1 = strategy.GetWriteLock())
         {
             using (var writeLock2 = strategy.GetWriteLock())
             {
                 // do nothing
             }
         }
     }
 }
示例#3
0
        public void DoubleWriteLockOnDifferentThreadsWaits()
        {
            using (ILockStrategy strategy = GetLockStrategy())
            {
                Thread t;
                using (var writeLock1 = strategy.GetWriteLock())
                {
                    t = new Thread(GetWriteLock);
                    t.Start(strategy);

                    //sleep and let new thread run and block
                    Thread.Sleep(50);

                    //assert that write thread has not terminated
                    Assert.IsTrue(t.IsAlive);
                } //release write lock

                Thread.Sleep(50);

                //assert that getwritelock did complete once first writelock was released it's call
                Assert.IsFalse(t.IsAlive);
            }
        }
 public ILock GetWriteLock(TimeSpan timeOut)
 {
     EnsureNotDisposed();
     return(_lockStrategy.GetWriteLock(timeOut));
 }
示例#5
0
 public ISharedCollectionLock GetWriteLock(TimeSpan timeOut)
 {
     EnsureNotDisposed();
     return(_lockController.GetWriteLock(timeOut));
 }