using System; /*https://github.com/dotnet/aspnetcore/blob/main/src/ObjectPool*/ namespace MemoryPools { /// /// The default . /// public class DefaultObjectPoolProvider : ObjectPoolProvider { /// /// The maximum number of objects to retain in the pool. /// public int MaximumRetained { get; set; } = Environment.ProcessorCount * 2; /// public override ObjectPool Create(IPooledObjectPolicy policy) { if (policy == null!) { throw new ArgumentNullException(nameof(policy)); } if (typeof(IDisposable).IsAssignableFrom(typeof(T))) { return new DisposableObjectPool(policy, MaximumRetained); } return new DefaultObjectPool(policy, MaximumRetained); } } }