コード例 #1
0
        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());
            }
        }
コード例 #2
0
ファイル: PoolManager.cs プロジェクト: zhuoweip/FrameScript
        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));
            }
        }