Table of Contents

Class MetalCommandQueuePool

Namespace
DotCompute.Backends.Metal.Utilities
Assembly
DotCompute.Backends.Metal.dll

Thread-safe pool of Metal command queues for concurrent kernel execution. Enables true parallelism by allowing multiple kernels to execute on different queues simultaneously.

public sealed class MetalCommandQueuePool : IDisposable
Inheritance
MetalCommandQueuePool
Implements
Inherited Members
Extension Methods

Constructors

MetalCommandQueuePool(nint, ILogger<MetalCommandQueuePool>, int?)

Initializes a new instance of the MetalCommandQueuePool.

public MetalCommandQueuePool(nint device, ILogger<MetalCommandQueuePool> logger, int? maxConcurrency = null)

Parameters

device nint

Metal device to create queues from.

logger ILogger<MetalCommandQueuePool>

Logger for diagnostics.

maxConcurrency int?

Maximum number of concurrent command queues (default: CPU core count).

Properties

Stats

Gets statistics about the command queue pool.

public CommandQueuePoolStats Stats { get; }

Property Value

CommandQueuePoolStats

Methods

AcquireQueueAsync(CancellationToken)

Gets a command queue from the pool for exclusive use. Blocks if all queues are currently in use.

public ValueTask<MetalCommandQueuePool.QueueEntry> AcquireQueueAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<MetalCommandQueuePool.QueueEntry>

A command queue entry with queue handle and metadata.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

ReleaseQueue(QueueEntry)

Returns a command queue to the pool for reuse.

public void ReleaseQueue(MetalCommandQueuePool.QueueEntry entry)

Parameters

entry MetalCommandQueuePool.QueueEntry

The queue entry to return.