Table of Contents

Class ReaderWriterLockStrategy

Namespace
Compendium.Core.Domain.Primitives
Assembly
Compendium.Core.dll

Reader-writer locking strategy that allows concurrent reads but exclusive writes. Optimal for scenarios with high read-to-write ratios.

public sealed class ReaderWriterLockStrategy : ILockingStrategy, IDisposable
Inheritance
ReaderWriterLockStrategy
Implements
Inherited Members

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

ExecuteReadAsync<T>(Func<Task<T>>, CancellationToken)

Executes an async read operation with appropriate locking.

public Task<T> ExecuteReadAsync<T>(Func<Task<T>> operation, CancellationToken cancellationToken = default)

Parameters

operation Func<Task<T>>

The operation to execute.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<T>

The result of the operation.

Type Parameters

T

The return type of the operation.

ExecuteRead<T>(Func<T>)

Executes a read operation with appropriate locking.

public T ExecuteRead<T>(Func<T> operation)

Parameters

operation Func<T>

The operation to execute.

Returns

T

The result of the operation.

Type Parameters

T

The return type of the operation.

ExecuteWrite(Action)

Executes a write operation with appropriate locking.

public void ExecuteWrite(Action operation)

Parameters

operation Action

The operation to execute.

ExecuteWriteAsync(Func<Task>, CancellationToken)

Executes an async write operation with appropriate locking.

public Task ExecuteWriteAsync(Func<Task> operation, CancellationToken cancellationToken = default)

Parameters

operation Func<Task>

The operation to execute.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task representing the async operation.