Skip to content

ExperimentConcurrencyLimiter

NexusLabs.Foundry.Evaluation

NexusLabs.Foundry.Evaluation.Experiments

ExperimentConcurrencyLimiter Class

Provides a semaphore-backed concurrency limiter suitable for sharing through dependency injection.

public sealed class ExperimentConcurrencyLimiter : NexusLabs.Foundry.Evaluation.Experiments.IExperimentConcurrencyLimiter, System.IAsyncDisposable

Inheritance System.Object 🡒 ExperimentConcurrencyLimiter

Implements IExperimentConcurrencyLimiter, System.IAsyncDisposable

Constructors

ExperimentConcurrencyLimiter(int) Constructor

Initializes a concurrency limiter.

public ExperimentConcurrencyLimiter(int maximumConcurrency);

Parameters

maximumConcurrency System.Int32

The maximum number of simultaneously active leases.

Methods

ExperimentConcurrencyLimiter.AcquireAsync(CancellationToken) Method

Acquires one concurrency lease.

public System.Threading.Tasks.ValueTask<System.IAsyncDisposable> AcquireAsync(System.Threading.CancellationToken cancellationToken);

Parameters

cancellationToken System.Threading.CancellationToken

The caller cancellation token.

Implements AcquireAsync(CancellationToken)

Returns

System.Threading.Tasks.ValueTask<System.IAsyncDisposable>
A lease that releases the acquired permit when disposed.

ExperimentConcurrencyLimiter.DisposeAsync() Method

Releases resources owned by the limiter.

public System.Threading.Tasks.ValueTask DisposeAsync();

Implements DisposeAsync()

Returns

System.Threading.Tasks.ValueTask
A completed disposal operation.