private Disposer Fetch(Type type) { Queue <Disposer> queue; if (!this.dictionary.TryGetValue(type, out queue)) { queue = new Queue <Disposer>(); this.dictionary.Add(type, queue); } Disposer obj; //从队列中获取 if (queue.Count > 0) { obj = queue.Dequeue(); obj.Id = IdGenerater.GenerateId32(); } else { obj = (Disposer)Activator.CreateInstance(type); //设置对象销毁时的回收函数 obj.SetDisposeAction(OnRecycle); } return(obj); }
protected Disposer() { this.Id = IdGenerater.GenerateId32(); }
protected AChannel(AService service) { this.Id = IdGenerater.GenerateId32(); this.service = service; }