public SingleTypePool(PoolParams poolParams, Func <T> factory) { this.poolParams = poolParams; this.factory = factory; emptyNodesPool = new EmptyNodesPool(poolParams); for (int i = 0; i < poolParams.PreloadedInstances; i++) { Push(Create()); } }
public void CreatePool <T>(PoolParams @params = default(PoolParams)) where T : class, IPoolable, new() { Type type = typeof(T); if (!poolTable.ContainsKey(type)) { poolTable.Add(typeof(T), new SingleTypePool <T>(@params)); } else { throw new InvalidOperationException(string.Format("A pool for type '{0}' already exists.", type.Name)); } }