Table of Contents

Class ReaderWriterLock

Namespace
log4net.Util
Assembly
log4net.dll

Defines a lock that supports single writers and multiple readers

public sealed class ReaderWriterLock
Inheritance
ReaderWriterLock
Inherited Members

Remarks

ReaderWriterLock is used to synchronize access to a resource. At any given time, it allows either concurrent read access for multiple threads, or write access for a single thread. In a situation where a resource is changed infrequently, a ReaderWriterLock provides better throughput than a simple one-at-a-time lock, such as Monitor.

If a platform does not support a System.Threading.ReaderWriterLock implementation then all readers and writers are serialized. Therefore the caller must not rely on multiple simultaneous readers.

Constructors

ReaderWriterLock()

Constructor

public ReaderWriterLock()

Remarks

Initializes a new instance of the ReaderWriterLock class.

Methods

AcquireReaderLock()

Acquires a reader lock

public void AcquireReaderLock()

Remarks

AcquireReaderLock() blocks if a different thread has the writer lock, or if at least one thread is waiting for the writer lock.

AcquireWriterLock()

Acquires the writer lock

public void AcquireWriterLock()

Remarks

This method blocks if another thread has a reader lock or writer lock.

ReleaseReaderLock()

Decrements the lock count

public void ReleaseReaderLock()

Remarks

ReleaseReaderLock() decrements the lock count. When the count reaches zero, the lock is released.

ReleaseWriterLock()

Decrements the lock count on the writer lock

public void ReleaseWriterLock()

Remarks

ReleaseWriterLock decrements the writer lock count. When the count reaches zero, the writer lock is released.