Beispiel #1
0
        //回收对象
        public void Push(object obj_)
        {
            Type     type = obj_.GetType();
            BasePool pool = GetPool(type);

            pool.Push(obj_);
        }
Beispiel #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();
            }
        }
Beispiel #3
0
        //清空对象池
        public void ClearPool(Type type_)
        {
            BasePool pool = GetPool(type_);

            if (pool != null)
            {
                pool.Clear();
            }
        }
Beispiel #4
0
        //-------∽-★-∽id∽-★-∽--------//

        public BasePool CreatePool(string id_)
        {
            if (m_id2pool.ContainsKey(id_))
            {
                return(m_id2pool[id_]);
            }
            BasePool pool = new BasePool();     //创建基本池

            m_id2pool[id_] = pool;
            return(pool);
        }
Beispiel #5
0
        public void Push(string id_, object obj_)
        {
            BasePool pool = GetPool(id_);

            pool.Push(obj_);
        }
Beispiel #6
0
        public object Pop(string id_)
        {
            BasePool pool = GetPool(id_);

            return(pool.Pop());
        }
Beispiel #7
0
        //
        public object Pop(Type type_)
        {
            BasePool pool = CreatePool(type_);

            return(pool.Pop());
        }