示例#1
0
 /// <summary>
 /// 创建事件,如果对象池中有则无需创建
 /// </summary>
 /// <param name="type"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 internal static ThreadEvent Create(string type, object data = null)
 {
     if (pools.Count > 0)
     {
         ThreadEvent e = pools[pools.Count - 1];
         e.type = type;
         e.data = data;
         return(e);
     }
     return(new ThreadEvent(type, data));
 }
示例#2
0
 public static ThreadEvent Create(string type)
 {
     if (pools.Count > 0)
     {
         ThreadEvent e = pools[pools.Count - 1];
         e.id   = ID++;
         e.type = type;
         pools.RemoveAt(pools.Count - 1);
         return(e);
     }
     return(new ThreadEvent(type));
 }
 public ThreadEvent ReadEvent()
 {
     while (readId < maxId)
     {
         if (list.ContainsKey(readId + 1))
         {
             ThreadEvent e = list[readId + 1];
             readId++;
             return(e);
         }
         else
         {
             readId++;
         }
     }
     return(null);
 }
        public static List <ThreadEvent> GetAllEvent(int threadId)
        {
            List <ThreadEvent> list = new List <ThreadEvent>();

            for (int i = 0; i < threads.Count; i++)
            {
                if (threads[i] != threadId)
                {
                    ThreadEventList threadEventList = threadList[threads[i]][threadId];
                    ThreadEvent     e = threadEventList.ReadEvent();
                    while (e != null)
                    {
                        list.Add(e);
                        e = threadEventList.ReadEvent();
                    }
                }
            }
            return(list);
        }
示例#5
0
 /// <summary>
 /// 把事件放回对象池
 /// </summary>
 /// <param name="e"></param>
 internal static void Release(ThreadEvent e)
 {
     pools.Add(e);
 }
 public void AddEvent(ThreadEvent e)
 {
     list.Add(e.Id, e);
     maxId = e.Id;
 }
示例#7
0
 public void AddEvent(int threadId, ThreadEvent e)
 {
     ThreadEventList.GetList(Id, threadId).AddEvent(e);
 }