Пример #1
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据管理∽-★-∽--------∽-★-∽------∽-★-∽--------//


        public T Pop <T>() where T : class
        {
            Type     type = typeof(T);
            TypePool pool = CreatePool(type);

            return(pool.Pop() as T);
        }
Пример #2
0
        //清空全部空闲
        //public void ClearAllIdles(Type type_)
        //{
        //    BasePool pool = GetPool(type_);
        //    if (pool != null)
        //    {
        //        pool.ClearAllIdles();
        //    }
        //}

        //public void ClearAllIdles()
        //{
        //    if (m_type2pool.Count == 0)
        //        return;

        //    foreach (KeyValuePair<Type, ClassPool> kvp in m_type2pool)
        //    {
        //        ClassPool v = kvp.Value;
        //        v.ClearAllIdles();
        //    }
        //}

        //清空对象池
        public void Clear()
        {
            if (m_type2pool.Count > 0)
            {
                foreach (KeyValuePair <Type, TypePool> kvp in m_type2pool)
                {
                    TypePool v = kvp.Value;
                    v.Clear();
                }
                m_type2pool.Clear();
            }


            if (m_t2pool.Count > 0)
            {
                foreach (KeyValuePair <Type, object> kvp in m_t2pool)
                {
                    ClassUtil.CallMethod(kvp.Value, "Clear");
                }
                m_t2pool.Clear();
            }


            if (m_id2pool.Count > 0)
            {
                foreach (KeyValuePair <string, BasePool> kvp in m_id2pool)
                {
                    BasePool v = kvp.Value;
                    v.Clear();
                }
                m_id2pool.Clear();
            }
        }
Пример #3
0
        public BasePool CreatePool(string id_, Type type_)
        {
            if (m_id2pool.ContainsKey(id_))
            {
                return(m_id2pool[id_]);
            }
            TypePool pool = new TypePool(type_);

            m_id2pool[id_] = pool;
            return(pool);
        }
Пример #4
0
        //-------∽-★-∽------∽-★-∽--------∽-★-∽数据操作∽-★-∽--------∽-★-∽------∽-★-∽--------//


        //-------∽-★-∽------∽-★-∽--------∽-★-∽pool相关∽-★-∽--------∽-★-∽------∽-★-∽--------


        //-------∽-★-∽Type∽-★-∽--------//


        //创建对象池
        public TypePool CreatePool(Type type_)
        {
            if (m_type2pool.ContainsKey(type_))
            {
                return(m_type2pool[type_]);
            }
            TypePool pool = new TypePool(type_);

            m_type2pool[type_] = pool;
            return(pool);
        }