public AsyncMutex(T initialValue)Initializes a new AsyncMutex<T> owning initialValue.
Parameters
initialValue- The initial protected value.
All Types / Ferrous.Concurrency
public sealed class AsyncMutex<T> : IDisposable
An async-capable data-owning mutual exclusion primitive inspired by tokio::sync::Mutex<T>. Compiled with .NET 11 runtime async (runtime-async=on) on net11.0.
Tpublic AsyncMutex(T initialValue)Initializes a new AsyncMutex<T> owning initialValue.
initialValuepublic ValueTask<AsyncMutexGuard<T>> LockAsync(CancellationToken cancellationToken = default) [MustUse]Asynchronously acquires the mutex and returns an AsyncMutexGuard<T>. Uses a zero-allocation fast path when uncontended.
cancellationTokenpublic bool TryLock(out AsyncMutexGuard<T> guard) [MustUse]Attempts to acquire the mutex synchronously without blocking.
guardtrue, contains the acquired AsyncMutexGuard<T>; otherwise, the default (unacquired) guard.public void Dispose()Releases the underlying SemaphoreSlim.