Show / Hide Table of Contents

Class QueuedSynchronizer

Provides a framework for implementing asynchronous locks and related synchronization primitives that rely on first-in-first-out (FIFO) wait queues.

Inheritance
object
Disposable
QueuedSynchronizer
AsyncAutoResetEvent
AsyncCountdownEvent
AsyncCounter
AsyncEventHub
AsyncExclusiveLock
AsyncManualResetEvent
AsyncReaderWriterLock
AsyncSharedLock
AsyncTrigger
QueuedSynchronizer<TContext>
Implements
IDisposable
Inherited Members
Disposable.IsDisposed
Disposable.IsDisposing
Disposable.IsDisposingOrDisposed
Disposable.CreateException()
Disposable.DisposedTask
Disposable.GetDisposedTask<T>()
Disposable.TrySetDisposedException<T>(TaskCompletionSource<T>)
Disposable.TrySetDisposedException(TaskCompletionSource)
Disposable.TryBeginDispose()
Disposable.Dispose()
Disposable.Dispose(IEnumerable<IDisposable>)
Disposable.DisposeAsync(IEnumerable<IAsyncDisposable>)
Disposable.Dispose<T>(ReadOnlySpan<T>)
Disposable.DisposeAsync(params IAsyncDisposable[])
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Threading
Assembly: DotNext.Threading.dll
Syntax
public class QueuedSynchronizer : Disposable, IDisposable
Remarks

This class is designed to provide better throughput rather than optimized response time. It means that it minimizes contention between concurrent calls and allows to process as many concurrent requests as possible by the cost of the execution time of a single method for a particular caller.

Properties

| Edit this page View Source

MeasurementTags

Sets a list of tags to be associated with each measurement.

Declaration
[CLSCompliant(false)]
public TagList MeasurementTags { init; }
Property Value
Type Description
TagList

Methods

| Edit this page View Source

CancelSuspendedCallers(CancellationToken)

Cancels all suspended callers.

Declaration
public void CancelSuspendedCallers(CancellationToken token)
Parameters
Type Name Description
CancellationToken token

The canceled token.

Exceptions
Type Condition
ArgumentOutOfRangeException

token is not in canceled state.

ObjectDisposedException

The object has been disposed.

| Edit this page View Source

Dispose(bool)

Releases all resources associated with this object.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

Indicates whether the Dispose(bool) has been called directly or from finalizer.

Overrides
Disposable.Dispose(bool)
Remarks

This method is not thread-safe and may not be used concurrently with other members of this instance.

| Edit this page View Source

Dispose(Exception?)

Releases all resources associated with this object.

Declaration
public void Dispose(Exception? reason)
Parameters
Type Name Description
Exception reason

The exeption to be passed to all suspended callers.

| Edit this page View Source

DisposeAsync()

Disposes this synchronization primitive gracefully.

Declaration
public ValueTask DisposeAsync()
Returns
Type Description
ValueTask

The task representing asynchronous result.

| Edit this page View Source

DisposeAsyncCore()

Releases managed resources associated with this object asynchronously.

Declaration
protected override ValueTask DisposeAsyncCore()
Returns
Type Description
ValueTask

The task representing asynchronous execution of this method.

Overrides
Disposable.DisposeAsyncCore()
Remarks

This method makes sense only if derived class implements IAsyncDisposable interface.

| Edit this page View Source

GetSuspendedCallers()

Gets a list of suspended callers respecting their order in wait queue.

Declaration
public IReadOnlyList<object?> GetSuspendedCallers()
Returns
Type Description
IReadOnlyList<object>

A list of suspended callers.

Remarks

This method is introduced for debugging purposes only.

See Also
TrackSuspendedCallers(Func<object>?)
| Edit this page View Source

SetCallerInformation(object)

Sets caller information in DEBUG configuration.

Declaration
[Conditional("DEBUG")]
public void SetCallerInformation(object information)
Parameters
Type Name Description
object information

The object that identifies the caller.

Remarks

It is recommended to inject caller information immediately before calling of WaitAsync method.

| Edit this page View Source

TrackSuspendedCallers(Func<object>?)

Enables capturing information about suspended callers in DEBUG configuration.

Declaration
[Conditional("DEBUG")]
public void TrackSuspendedCallers(Func<object>? callerInfoProvider = null)
Parameters
Type Name Description
Func<object> callerInfoProvider

The optional factory of the information about the caller.

Remarks

If callerInfoProvider is provided then no need to use SetCallerInformation(object).

Implements

IDisposable

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾