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
devicenintMetal device to create queues from.
loggerILogger<MetalCommandQueuePool>Logger for diagnostics.
maxConcurrencyint?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
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
cancellationTokenCancellationTokenCancellation 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
entryMetalCommandQueuePool.QueueEntryThe queue entry to return.