Ejemplo n.º 1
0
        protected override PoolUnitList <T> CreateNewUnitList <T>()
        {
            PoolUnitList <T> list = new PoolUnitList <T>();

            list.SetPool(this);
            return(list);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 在缓冲池中获取指定单元类型的列表,
        /// 如果该单元类型不存在,则立刻创建。
        /// </summary>
        /// <returns>单元列表</returns>
        public PoolUnitList <T> GetTargetList <TT>(string key = null) where TT : T
        {
            if (string.IsNullOrEmpty(key))
            {
                key = typeof(T).ToString();
            }
            PoolUnitList <T> list = null;

            poolTale.TryGetValue(key, out list);
            if (list == null)
            {
                list = CreateNewUnitList <T>();
                poolTale.Add(key, list);
            }
            return(list);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 接受父列表对象的设置
 /// </summary>
 /// <param name="parentList">父列表对象</param>
 public virtual void SetParentList(object parentList)
 {
     this.parentList = parentList as PoolUnitList <PoolUnit>;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取一个闲置的单元
        /// </summary>
        public TT GetIdleUnit <TT>(string key = null) where TT : T
        {
            PoolUnitList <T> list = GetTargetList <TT>(key);

            return(list.GetIdleUnit <TT>() as TT);
        }