Example #1
0
 public TimerTaskPool Preload(int count)
 {
     for (int i = 0; i < count; i++)
     {
         var t = new TimerTask();
         ReleaseATimer(t);
     }
     return(this);
 }
Example #2
0
 public void ReturnToPool(TimerTask task)
 {
     //for (int i = 0; i < ReleaseList.Length; i++)
     //{
     //    var hand = ReleaseList[i];
     //    if (hand == null)
     //    {
     //        ReleaseList[i] = task;
     //        return;
     //    }
     //}
 }
Example #3
0
 /// <summary>
 /// 归还timer,如果塞不下,就不要了
 /// </summary>
 /// <param name="tim"></param>
 public void ReleaseATimer(TimerTask tim)
 {
     tim.Clear();
     for (int i = 0; i < EmptyTimerArr.Length; i++)
     {
         var t = EmptyTimerArr[i];
         if (t == null)
         {
             EmptyTimerArr[i] = tim;
             return;
         }
     }
 }
Example #4
0
            /// <summary>
            /// 从池里拿个,如果没有就创个
            /// </summary>
            /// <returns></returns>
            public TimerTask GetATimer()
            {
                for (int i = 0; i < EmptyTimerArr.Length; i++)
                {
                    var t = EmptyTimerArr[i];
                    if (t != null)
                    {
                        EmptyTimerArr[i] = null;
                        return(t);
                    }
                }
                var item = new TimerTask();

                return(item);
            }
Example #5
0
 public void RemoveUpdateTimer(TimerTask task)
 {
     //RemoveList.Remove(task);
     HandleList.Remove(task);
 }
Example #6
0
 public void AddUpdateTimer(TimerTask task)
 {
     // AddList.Add(task);
     HandleList.Add(task);
 }