Ferrous API Reference

All Types / Ferrous.Concurrency

struct MutexGuard<T> [MustUse]

public ref struct MutexGuard<T>

A stack-allocated RAII guard providing exclusive access to the value owned by a Mutex<T>. Because this is a ref struct, it cannot escape to the heap or be held across await.

Type Parameters
T
The type of the protected value.

Properties

public ref T Value

Gets a managed reference to the protected value.

Exceptions
ObjectDisposedException
Thrown if this guard has already been disposed or is uninitialized.

Methods

public void Dispose()

Releases the underlying Mutex<T> lock. Safe to call more than once.