public void PushExcute(Callback <List <object> > cb, params object[] args) { bool newTaskFailed = true; SimplePool <Task> pool = mTaskTypePools.GetOrNew <SimplePool <Task> >(); if (null != pool) { Task task = pool.Alloc(); if (null != task) { task.Init(cb, args); mTaskMaskQueue.Enqueue(task.Run); newTaskFailed = false; } } if (newTaskFailed) { mTaskMaskQueue.Enqueue(() => { List <object> ps = new List <object>(); ps.AddRange(args); cb(ps); }); } }
public void FireEvent(int key, params object[] args) { // 先判断目前的事件队列中是否有这个事件,如果有的话,则刷新为最新。因为在同一帧中两次事件的没有作用 Event2 e = null; for (int i = 0; i < mFiredEventList.Count; ++i) { if (mFiredEventList [i].GetKey() == key) { e = mFiredEventList [i]; break; } } if (e == null) { e = mEventPool.Alloc(); e.Set(key, args); mFiredEventList.Add(e); } else { e.Set(key, args); } }
// Callback<params object[] args> public void PushExcute <T0>(Callback <T0> cb, T0 t) { bool newTaskFailed = true; SimplePool <Task <T0> > pool = mTaskTypePools.GetOrNew <SimplePool <Task <T0> > >(); if (null != pool) { Task <T0> task = pool.Alloc(); if (null != task) { task.Init(cb, t); mTaskMaskQueue.Enqueue(task.Run); newTaskFailed = false; } } if (newTaskFailed) { mTaskMaskQueue.Enqueue(() => { cb(t); }); } }