public void TestReadLockTimeout()
 {
     using (ILockStrategy l = LockFactory.Create())
     using (new ThreadedWriter(l))
     using (ReadLock r = new ReadLock(l, 0))
         Assert.IsFalse(r.HasReadLock);
 }
 public void TestIdiotReaderUsesDispose()
 {
     using (ILockStrategy l = LockFactory.Create())
     using (ReadLock r = new ReadLock(l, 0))
     {
         Assert.IsTrue(r.HasReadLock);
         ((IDisposable)r).Dispose(); //You cannot do this, the using statement has a 'copy' of ReadLock, don't call dispose.
     }
 }
Exemple #3
0
 /// <summary>
 /// Returns a reader lock that can be elevated to a write lock
 /// </summary>
 public ReadLock Read()
 {
     return(ReadLock.Acquire(this, -1));
 }
Exemple #4
0
 /// <summary>
 /// Returns a reader lock that can be elevated to a write lock
 /// </summary>
 /// <exception cref="System.TimeoutException"/>
 public ReadLock Read(int timeout)
 {
     return(ReadLock.Acquire(this, timeout));
 }
Exemple #5
0
 /// <summary>
 /// Returns a reader lock that can be elevated to a write lock
 /// </summary>
 /// <exception cref="System.TimeoutException"/>
 public ReadLock Read(int millisecondsTimeout)
 {
     return(ReadLock.Acquire(this, millisecondsTimeout));
 }
 public void TestReadLockSuccess()
 {
     using (ILockStrategy l = LockFactory.Create())
     using (ReadLock r = new ReadLock(l, 0))
         Assert.IsTrue(r.HasReadLock);
 }