Exemple #1
0
                public static TimerChangeEntry GetInstance(Timer t, int newIndex, bool isAdd)
                {
                    TimerChangeEntry e = null;

                    lock (m_InstancePool)
                    {
                        if (m_InstancePool.Count > 0)
                        {
                            e = m_InstancePool.Dequeue();
                        }
                    }

                    if (e != null)
                    {
                        e.m_Timer    = t;
                        e.m_NewIndex = newIndex;
                        e.m_IsAdd    = isAdd;
                    }
                    else
                    {
                        e = new TimerChangeEntry(t, newIndex, isAdd);
                    }

                    return(e);
                }
Exemple #2
0
        private void ProcessChangeQueue(DateTime now)
        {
            lock ( m_ChangeQueue )
            {
                while (m_ChangeQueue.Count > 0)
                {
                    TimerChangeEntry tce   = m_ChangeQueue.Dequeue();
                    Timer            timer = tce.Timer;
                    int newIndex           = tce.NewIndex;

                    if (timer.m_List != null)
                    {
                        timer.m_List.Remove(timer);
                    }

                    if (tce.IsAdd)
                    {
                        timer.m_Next  = now + timer.Delay;
                        timer.m_Index = 0;
                    }

                    if (newIndex >= 0)
                    {
                        timer.m_List = m_Timers[newIndex];
                        timer.m_List.Add(timer);
                    }
                    else
                    {
                        timer.m_List = null;
                    }

                    tce.Free();
                }
            }
        }
Exemple #3
0
            private static void ProcessChangeQueue()
            {
                while (mChangeQueue.Count > 0)
                {
                    TimerChangeEntry tce   = (TimerChangeEntry)mChangeQueue.Dequeue();
                    Timer            timer = tce.mTimer;
                    int newIndex           = tce.mNewIndex;

                    if (timer.mList != null)
                    {
                        timer.mList.Remove(timer);
                    }

                    if (tce.mIsAdd)
                    {
                        timer.mNext  = DateTime.Now + timer.mDelay;
                        timer.mIndex = 0;
                    }

                    if (newIndex >= 0)
                    {
                        timer.mList = mTimers[newIndex];
                        timer.mList.Add(timer);
                    }
                    else
                    {
                        timer.mList = null;
                    }

                    tce.Free();
                }
            }
Exemple #4
0
                public static TimerChangeEntry GetInstance(Timer t, int newIndex, bool isAdd)
                {
                    TimerChangeEntry e;

                    if (mInstancePool.Count > 0)
                    {
                        e = mInstancePool.Dequeue();

                        if (e == null)
                        {
                            e = new TimerChangeEntry(t, newIndex, isAdd);
                        }
                        else
                        {
                            e.mTimer    = t;
                            e.mNewIndex = newIndex;
                            e.mIsAdd    = isAdd;
                        }
                    }
                    else
                    {
                        e = new TimerChangeEntry(t, newIndex, isAdd);
                    }

                    return(e);
                }
Exemple #5
0
        private void Change(Timer timer, int newIndex, bool isAdd)
        {
            var entry = TimerChangeEntry.GetInstance(timer, newIndex, isAdd);

            lock (m_ChangeQueue)
                m_ChangeQueue.Enqueue(entry);
        }
Exemple #6
0
            public static void Change(Timer t, int newIndex, bool isAdd)
            {
                TimerChangeEntry entry = TimerChangeEntry.GetInstance(t, newIndex, isAdd);

                lock (m_ChangeQueue.SyncRoot)
                    m_ChangeQueue.Enqueue(entry);
                m_Signal.Set();
            }
Exemple #7
0
        public void AddTimerSliceTest()
        {
            TimerChangeEntry target = new TimerChangeEntry(); // TODO: 初始化为适当的值
            bool             actual;

            actual = target.AddTimerSlice;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #8
0
        public void TimerPriorityTest()
        {
            TimerChangeEntry target = new TimerChangeEntry(); // TODO: 初始化为适当的值
            long             actual;

            actual = target.TimerPriority;
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemple #9
0
            public static void Change(Timer t, int newIndex, bool isAdd)
            {
                lock (m_Changed)
                {
                    m_Changed[t] = TimerChangeEntry.GetInstance(t, newIndex, isAdd);
                }

                m_Signal.Set();
            }
Exemple #10
0
        public void TimerChangeEntryConstructorTest()
        {
            TimeSlice        tTimer   = null;  // TODO: 初始化为适当的值
            long             newIndex = 0;     // TODO: 初始化为适当的值
            bool             isAdd    = false; // TODO: 初始化为适当的值
            TimerChangeEntry target   = new TimerChangeEntry(tTimer, newIndex, isAdd);

            Assert.Inconclusive("TODO: 实现用来验证目标的代码");
        }
Exemple #11
0
 public static void Change(Timer t, int newIndex, bool isAdd)
 {
     mChangeQueue.Enqueue(TimerChangeEntry.GetInstance(t, newIndex, isAdd));
     mSignal.Set();
 }
Exemple #12
0
                public static TimerChangeEntry GetInstance( Timer t, int newIndex, bool isAdd )
                {
                    TimerChangeEntry e;

                    if ( m_InstancePool.Count > 0 )
                    {
                        e = (TimerChangeEntry)m_InstancePool.Dequeue();

                        if ( e == null )
                            e = new TimerChangeEntry( t, newIndex, isAdd );
                        else
                        {
                            e.m_Timer = t;
                            e.m_NewIndex = newIndex;
                            e.m_IsAdd = isAdd;
                        }
                    }
                    else
                    {
                        e = new TimerChangeEntry( t, newIndex, isAdd );
                    }

                    return e;
                }
Exemple #13
0
 public static void Change(Server.Timer t, int newIndex, bool isAdd)
 {
     Server.Timer.TimerThread.m_ChangeQueue.Enqueue(TimerChangeEntry.GetInstance(t, newIndex, isAdd));
 }