public void DoubleWriteLockThrows() { using (ILockStrategy strategy = GetLockStrategy()) { using (var writeLock1 = strategy.GetWriteLock()) { using (var writeLock2 = strategy.GetWriteLock()) { //do nothing } } } }
protected void DoubleWriteLock() { using (ILockStrategy strategy = this.GetLockStrategy()) { using (var writeLock1 = strategy.GetWriteLock()) { using (var writeLock2 = strategy.GetWriteLock()) { // do nothing } } } }
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)); }
public ISharedCollectionLock GetWriteLock(TimeSpan timeOut) { EnsureNotDisposed(); return(_lockController.GetWriteLock(timeOut)); }