Class HighPerformanceObjectPool<T>
- Namespace
- DotCompute.Memory
- Assembly
- DotCompute.Memory.dll
High-performance object pool optimized for compute workloads with:
- Lock-free operations using ConcurrentStack
- Automatic pool size management
- Thread-local storage for hot paths
- Performance metrics and monitoring
- Configurable eviction policies
- NUMA-aware allocation when available Target: 90%+ allocation reduction for frequent operations
public sealed class HighPerformanceObjectPool<T> : ObjectPool<T>, IDisposable where T : class
Type Parameters
TThe type of objects to pool.
- Inheritance
-
ObjectPool<T>HighPerformanceObjectPool<T>
- Implements
- Inherited Members
- Extension Methods
Constructors
HighPerformanceObjectPool(Func<T>, Action<T>?, Func<T, bool>?, PoolConfiguration?, ILogger?)
Initializes a new high-performance object pool.
public HighPerformanceObjectPool(Func<T> createFunc, Action<T>? resetAction = null, Func<T, bool>? validateFunc = null, PoolConfiguration? config = null, ILogger? logger = null)
Parameters
createFuncFunc<T>Function to create new objects.
resetActionAction<T>Optional action to reset objects before reuse.
validateFuncFunc<T, bool>Optional function to validate objects before reuse.
configPoolConfigurationPool configuration settings.
loggerILoggerOptional logger for diagnostics.
Properties
Statistics
Gets pool performance statistics.
public PoolStatistics Statistics { get; }
Property Value
Methods
Dispose()
Performs dispose.
public void Dispose()
Get()
Gets an object from the pool with optimized thread-local caching.
public override T Get()
Returns
- T
Return(T)
Returns an object to the pool with optimized thread-local caching.
public override void Return(T obj)
Parameters
objT
TriggerMaintenance()
Forces pool maintenance (cleanup, resizing, etc.).
public void TriggerMaintenance()