/*https://github.com/dotnet/aspnetcore/blob/main/src/ObjectPool*/ namespace MemoryPools { public abstract class ObjectPool where T : class { /// /// Gets an object from the pool if one is available, otherwise creates one. /// /// A . public abstract T Get(); /// /// Return an object to the pool. /// /// The object to add to the pool. public abstract void Return(T obj); } /// /// Methods for creating instances. /// public static class ObjectPool { /// public static ObjectPool Create(IPooledObjectPolicy policy = null!) where T : class, new() { var provider = new DefaultObjectPoolProvider(); return provider.Create(policy ?? new DefaultPooledObjectPolicy()); } } }