Ferrous API Reference

All Types / Ferrous.Concurrency

class RwLock<T>

public sealed class RwLock<T> : IDisposable

A data-owning reader-writer lock inspired by Rust's std::sync::RwLock<T>. Multiple readers may hold ReadGuard<T> concurrently, while writers acquire exclusive access via WriteGuard<T>.

Type Parameters
T
The type of the protected value.

Constructors

public RwLock(T initialValue)

Initializes a new RwLock<T> owning initialValue.

Methods

public ReadGuard<T> Read()
[MustUse]

Acquires shared read access and returns a stack-allocated ReadGuard<T>.

public bool TryRead(out ReadGuard<T> guard)
[MustUse]

Attempts to acquire shared read access without blocking.

public WriteGuard<T> Write()
[MustUse]

Acquires exclusive write access and returns a stack-allocated WriteGuard<T>.

public bool TryWrite(out WriteGuard<T> guard)
[MustUse]

Attempts to acquire exclusive write access without blocking.

public void Dispose()