DotNext.Threading by .NET Foundation and Contributors

<PackageReference Include="DotNext.Threading" Version="5.12.0" />

 QueuedSynchronizer<TContext>

public abstract class QueuedSynchronizer<TContext> : QueuedSynchronizer
Provides low-level infrastructure for writing custom synchronization primitives.
protected QueuedSynchronizer(int? concurrencyLevel)

Initializes a new synchronization primitive.

protected ValueTask AcquireAsync(TContext context, TimeSpan timeout, CancellationToken token)

Implements acquire semantics: attempts to move this object to acquired state asynchronously.

protected ValueTask AcquireAsync(TContext context, CancellationToken token)

Implements acquire semantics: attempts to move this object to acquired state asynchronously.

protected virtual void AcquireCore(TContext context)

Modifies the internal state according to acquisition semantics.

protected abstract bool CanAcquire(TContext context)

Tests whether the lock acquisition can be done successfully before calling AcquireCore.

protected void Release()

Implements release semantics: attempts to resume the suspended callers.

protected void Release(TContext context)

Implements release semantics: attempts to resume the suspended callers.

protected virtual void ReleaseCore(TContext context)

Modifies the internal state according to release semantics.

protected bool TryAcquire(TContext context)

Implements acquire semantics: attempts to move this object to acquired state synchronously.

protected ValueTask<bool> TryAcquireAsync(TContext context, TimeSpan timeout, CancellationToken token)

Implements acquire semantics: attempts to move this object to acquired state asynchronously.