internal WriteLockScope(SafeReaderWriterLock owner) { try { } finally { owner.EnterWriteLock(); this.owner = owner; } }
internal MultipleWriteLocksScope(SafeReaderWriterLock a, SafeReaderWriterLock b) { try { } finally { SafeReaderWriterLock.EnterMultipleWriteLocks(a, b); this.a = a; this.b = b; } }
public void Dispose() { try { } finally { if (this.owner != null) { this.owner.ExitWriteLock(); this.owner = null; } } }
public void Dispose() { try { } finally { if ((this.a != null) && (this.b != null)) { SafeReaderWriterLock.ExitMultipleWriteLocks(this.a, this.b); this.a = null; this.b = null; } } }
public static void ExitMultipleReadLocks(SafeReaderWriterLock a, SafeReaderWriterLock b) { Validate.Begin().IsNotNull <SafeReaderWriterLock>(a, "a").IsNotNull <SafeReaderWriterLock>(b, "b").Check(); Thread.BeginCriticalRegion(); if (a.id == b.id) { a.ExitReadLock(); } else if (a.id < b.id) { a.ExitReadLock(); b.ExitReadLock(); } else { b.ExitReadLock(); a.ExitReadLock(); } Thread.EndCriticalRegion(); }
public static MultipleWriteLocksScope UseMultipleWriteLocks(SafeReaderWriterLock a, SafeReaderWriterLock b) => new MultipleWriteLocksScope(a, b);