コード例 #1
0
ファイル: ReadWriteLock.cs プロジェクト: Dextarius/Locksmith
 //- TODO : Since this is an explicit implementation, it the only thing that should
 //  end up calling it is a using() statement.  Still, we should weigh the convenience
 //  of this against the fact that it could create harder to find errors if someone
 //  used the lock in a way I didn't anticipate, and ends up calling this at the wrong time.
 void IDisposable.Dispose()
 {
     if (lockState.IsReadLocked())
     {
         Locksmith.ExitReadLock(ref lockState, readLockObject, this);
     }
     else if (lockState.IsWriteLocked())
     {
         Locksmith.ExitWriteLock(ref lockState, readLockObject, this);
     }
     else
     {
         throw new SynchronizationLockException(
                   $"A process used the Dispose() method of a {nameof(ReaderWriterLock)} to try to exit a lock, " +
                   $"but the lock was not in a locked state");
     }
 }
コード例 #2
0
ファイル: ReadWriteLock.cs プロジェクト: Dextarius/Locksmith
            public ReaderWriterLock Upgrade()
            {
                Locksmith.Upgrade(ref lockState, this);

                return(this);
            }
コード例 #3
0
ファイル: ReadWriteLock.cs プロジェクト: Dextarius/Locksmith
            public ReaderWriterLock Downgrade()
            {
                Locksmith.EnterReadLock(ref lockState, readLockObject);

                return(this);
            }
コード例 #4
0
ファイル: ReadWriteLock.cs プロジェクト: Dextarius/Locksmith
            public ReaderWriterLock WriteLock()
            {
                Locksmith.EnterWriteLock(ref lockState, this);

                return(this);
            }