Class MetalCommandBufferPool
- Namespace
- DotCompute.Backends.Metal.Utilities
- Assembly
- DotCompute.Backends.Metal.dll
Pool for managing Metal command buffers to reduce allocation overhead.
public sealed class MetalCommandBufferPool : IDisposable
- Inheritance
-
MetalCommandBufferPool
- Implements
- Inherited Members
- Extension Methods
Constructors
MetalCommandBufferPool(nint, ILogger<MetalCommandBufferPool>, int)
Initializes a new instance of the MetalCommandBufferPool.
public MetalCommandBufferPool(nint commandQueue, ILogger<MetalCommandBufferPool> logger, int maxPoolSize = 16)
Parameters
commandQueuenintThe Metal command queue to create buffers from.
loggerILogger<MetalCommandBufferPool>Logger for diagnostics.
maxPoolSizeintMaximum number of buffers to keep in pool.
Properties
Stats
Gets statistics about the command buffer pool. Note: Since command buffers are no longer pooled for reuse, AvailableBuffers and CurrentPoolSize are always 0.
public CommandBufferPoolStats Stats { get; }
Property Value
Methods
Cleanup()
Performs cleanup of stale buffers from the pool. Since command buffers are no longer pooled for reuse, this only cleans up leaked active buffers.
public void Cleanup()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetCommandBuffer()
Gets a command buffer from the pool or creates a new one. NOTE: Metal command buffers are one-shot objects and cannot be reused after commit. This method always creates a fresh command buffer.
public nint GetCommandBuffer()
Returns
- nint
A command buffer handle.
GetStats()
Gets statistics about the command buffer pool (API compatibility method).
public CommandBufferPoolStats GetStats()
Returns
ReturnCommandBuffer(nint)
Returns a command buffer to the pool for cleanup. NOTE: Metal command buffers cannot be reused after commit, so they are always disposed. This method exists for API compatibility and proper tracking cleanup.
public void ReturnCommandBuffer(nint buffer)
Parameters
buffernintThe command buffer to dispose.