示例#1
0
 private ulong AddEngineTimer(AbsTimerData p)
 {
     lock (m_QueueLock)
     {
         m_EngineTimeQueue.Enqueue(p.TimerId, p, p.NextTick);
         m_TimerDict.ForceAdd(p.TimerId, p);
     }
     return(p.TimerId);
 }
示例#2
0
 public static int GetTimerCounter(ulong timerId)
 {
     if (Instance.m_TimerDict.ContainsKey(timerId))
     {
         AbsTimerData data = Instance.m_TimerDict[timerId];
         return(data.Counter);
     }
     else
     {
         return(-1);
     }
 }
示例#3
0
        private void UpdateRealTime()
        {
            float gameDuration = Time.realtimeSinceStartup;

            s_RealDeltaTime        = gameDuration - s_RealTimeSinceStartup;
            s_RealTimeSinceStartup = gameDuration;
            while (m_RealTimeQueue.Count != 0)
            {
                AbsTimerData p;
                lock (m_QueueLock)
                    p = m_RealTimeQueue.Peek();

                if (m_RemoveTimeList.Contains(p.TimerId))
                {
                    m_RemoveTimeList.Remove(p.TimerId);
                    lock (m_QueueLock)
                    {
                        m_RealTimeQueue.Dequeue();
                        m_TimerDict.ForceRemove(p.TimerId);
                    }
                    continue;
                }

                if (!p.IsFrameAction)
                {
                    if (s_RealTimeSinceStartup < p.NextTick)
                    {
                        break;
                    }

                    lock (m_QueueLock)
                    {
                        m_RealTimeQueue.Dequeue();
                        m_TimerDict.ForceRemove(p.TimerId);
                    }
                    if (p.Valid)
                    {
                        if (p.Interval > 0)
                        {
                            p.NextTick += (ulong)p.Interval;
                            lock (m_QueueLock)
                                m_RealTimeAddQueue.Enqueue(p);
                            p.DoAction(s_RealDeltaTime);
                        }
                        else
                        {
                            p.DoAction(s_RealDeltaTime);
                        }
                    }
                }
                else
                {
                    lock (m_QueueLock)
                    {
                        m_RealTimeQueue.Dequeue();
                        m_TimerDict.ForceRemove(p.TimerId);
                        if (p.Valid)
                        {
                            m_RealTimeAddQueue.Enqueue(p);
                            p.DoAction(s_RealDeltaTime);
                        }
                    }
                }
            }

            while (m_RealTimeAddQueue.Count != 0)
            {
                lock (m_QueueLock)
                {
                    AbsTimerData p = m_RealTimeAddQueue.Dequeue();
                    m_RealTimeQueue.Enqueue(p.TimerId, p, p.NextTick);
                    m_TimerDict.ForceAdd(p.TimerId, p);
                }
            }
        }