Example #1
0
 public SubObjectPoolBase(ObjectPoolData data)
 {
     _data         = data;
     _activeList   = new List <T>();
     _inactiveList = new List <T>();
     AutoDestroy(data);
 }
Example #2
0
        /// <summary>
        /// 添加池,返回值为是否添加成功
        /// </summary>
        /// <param name="name"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public virtual bool AddSubPool(ObjectPoolData data)
        {
            if (!_poolDic.ContainsKey(data.Name))
            {
                _poolDic[data.Name] = GetNewSubPool(data);
                return(true);
            }

            return(false);
        }
Example #3
0
        private async void AutoDestroy(ObjectPoolData data)
        {
            if (!data.IsAutoDestroy)
            {
                return;
            }

            while (true)
            {
                await Task.Delay(TimeSpan.FromSeconds(data.DestroyIntervalTime));

                AutoDestroy(100, data.ActiveLimitNum);
            }
        }
Example #4
0
 protected abstract SubObjectPoolBase <T> GetNewSubPool(ObjectPoolData dat);