Class ReaderWriterLock
- Namespace
- Jitter2.Parallelization
- Assembly
- Jitter2.dll
Allows concurrent readers or one exclusive writer.
public sealed class ReaderWriterLock
- Inheritance
-
ReaderWriterLock
- Inherited Members
Remarks
Waiting threads spin, so use this lock only for short operations with infrequent writes.
Release each acquired lock exactly once, on the thread that acquired it. Do not acquire the lock again while holding it or switch directly between a read lock and a write lock.
Methods
EnterReadLock()
Acquires the read lock.
public void EnterReadLock()
Remarks
Multiple threads can hold the read lock simultaneously. This method blocks while a writer holds the lock. Release it with ExitReadLock() on the same thread.
EnterWriteLock()
Acquires the write lock with exclusive access.
public void EnterWriteLock()
Remarks
This method blocks until all readers and other writers have released the lock. Release it with ExitWriteLock() on the same thread.
ExitReadLock()
Releases a read lock previously acquired by the current thread.
public void ExitReadLock()
Remarks
Must be called exactly once for each successful call to EnterReadLock() and on the same thread that acquired the lock.
ExitWriteLock()
Releases the write lock held by the current thread.
public void ExitWriteLock()
Remarks
Must be called exactly once after a successful call to EnterWriteLock() and on the same thread that acquired the lock.