Table of Contents

Struct ReaderWriterLock

Namespace
Jitter2.Parallelization
Assembly
Jitter2.dll

Provides a lightweight reader-writer lock optimized for rare write operations.

public struct ReaderWriterLock
Inherited Members

Remarks

Multiple readers can hold the lock concurrently, but writers have exclusive access. This implementation uses spin-waiting and is best suited for short critical sections.

Thread-safe. All methods use atomic operations and memory barriers.

Methods

EnterReadLock()

Acquires the read lock. Blocks while a writer holds the lock.

public void EnterReadLock()

Remarks

Multiple threads can hold the read lock simultaneously. Call ExitReadLock() to release.

EnterWriteLock()

Acquires the write lock with exclusive access. Blocks until all readers and writers release.

public void EnterWriteLock()

Remarks

Only one thread can hold the write lock at a time. Call ExitWriteLock() to release.

ExitReadLock()

Exits the read section.

public void ExitReadLock()

ExitWriteLock()

Exits the write section.

public void ExitWriteLock()