private void forceTime(float now) { List <IAutoReleaseRef> clearList = new List <IAutoReleaseRef>(); foreach (IAutoReleaseRef res in pool.Keys) { if (now - pool[res] > TIMEOUT) { clearList.Add(res); } } int len = clearList.Count; if (len > 0) { foreach (IAutoReleaseRef res in clearList) { res.__dispose(); pool.Remove(res); } } if (pool.Count == 0) { TickManager.Remove(tick); } }
private void _add(IAutoReleaseRef value) { if (pool.ContainsKey(value)) { pool[value] = Time.realtimeSinceStartup; return; } pool.Add(value, Time.realtimeSinceStartup); TickManager.Add(tick); }
private void add(float delayTime, Action <float> handler) { __addHandle(handler, Time.time + delayTime, true); if (len > 0) { TickManager.Add(render); } else if (firstNode != null) { TickManager.Add(render); Debug.LogError("callLater has a bug+" + len); } }
private void render(float deltaTime) { if (len > 0) { dispatching = true; SignalNode <float> t = firstNode; List <SignalNode <float> > temp = getSignalNodeList(); float now = Time.time; while (t != null) { if (t.active == NodeActiveState.Runing) { if (now > t.data) { Remove(t.action); t.action(t.data); } } temp.Add(t); t = t.next; } dispatching = false; int l = temp.Count; for (int i = 0; i < l; i++) { SignalNode <float> item = temp[i]; if (item.active == NodeActiveState.TodoDelete) { _remove(item, item.action); } else if (item.active == NodeActiveState.TodoAdd) { item.active = NodeActiveState.Runing; } } recycle(temp); } else { TickManager.Remove(render); } }