ReaderWriterLockSlimExtensions
Namespace: SnowBank.Threading · class
Extensions methods for working with ReaderWriterLockSlim
Methods
GetReadLock
static ReadLockDisposable GetReadLock(ReaderWriterLockSlim self)
Takes a disposable read lock
self— Lock that should be used, ornull
Returns: Disposable token that will release the lock when Dispose is called
If is null, and empty "no-op" token will be returned instead
using(lock.GetReadLock()) { /* ... read internal state ... */ }
GetUpgradableReadLock
static UpgradeableReadLockDisposable GetUpgradableReadLock(ReaderWriterLockSlim self)
Takes a disposable upgradable read lock
self— Lock that should be used, ornull
Returns: Disposable token that will release the lock when Dispose is called
If is null, and empty "no-op" token will be returned instead
using(lock.GetUpgradableReadLock()) { /* ... read internal state ... */ }
GetWriteLock
static WriteLockDisposable GetWriteLock(ReaderWriterLockSlim self)
Takes a disposable write lock
self— Lock that should be used, ornull
Returns: Disposable token that will release the lock when Dispose is called
If is null, and empty "no-op" token will be returned instead
using(lock.GetWriteLock()) { /* ... modify internal state ... */ }