Esempio n. 1
0
            private void RemoveInternal(UpdateDelegate update)
            {
                if (update == null)
                {
                    return;
                }
                int        key = update.GetHashCode();
                UpdateItem updater;
                int        removeAt = -1;

                if (mUpdating)
                {
                    if (mUpdaters.TryGetValue(key, out updater))
                    {
                        mUpdaters.Remove(key);
                        removeAt = updater.index;
                        if (mInterior >= updater.index)
                        {
                            mInterior--;
                        }
                    }
                    else if (mNewUpdaters.RemoveFromQueue(key))
                    {
                        removeAt = mInterior + mNewCount;
                        mNewCount--;
                        if (mNewCount > 0)
                        {
                            mNewPriority = mNewUpdaters.Peek().priority;
                        }
                    }
                }
                else
                {
                    if (mUpdaters.TryGetValue(key, out updater))
                    {
                        mUpdaters.Remove(key);
                        removeAt = updater.index;
                    }
                    else
                    {
                        UpdateItem u;
                        int        p;
                        if (mNewUpdaters.RemoveFromQueue(key, out u, out p))
                        {
                            UpdateItem.Cache(u);
                        }
                    }
                }
                if (removeAt >= 0)
                {
                    UpdateItem.Cache(mSortedUpdaters[removeAt]);
                    mSortedUpdaters.RemoveAt(removeAt);
                    for (int i = mSortedUpdaters.Count - 1; i >= removeAt; i--)
                    {
                        UpdateItem u = mSortedUpdaters[i];
                        u.index = i;
                    }
                }
            }
        /// <summary>
        /// 周期调用触发任务
        /// </summary>
        public static void Tick()
        {
            m_unTick += (uint)m_stopWatch.ElapsedMilliseconds;
            m_stopWatch.Reset();
            m_stopWatch.Start();

            while (m_queue.Count != 0)
            {
                AbsTimerData p;
                lock (m_queueLock)
                    p = m_queue.Peek();
                if (m_unTick < p.UnNextTick)
                {
                    break;
                }
                lock (m_queueLock)
                    m_queue.Dequeue();
                if (p.NInterval > 0)
                {
                    p.UnNextTick += (ulong)p.NInterval;
                    lock (m_queueLock)
                        m_queue.Enqueue(p.NTimerId, p, p.UnNextTick);
                    p.DoAction();
                }
                else
                {
                    p.DoAction();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 周期调用触发任务
        /// </summary>
        public static void Tick()
        {
            m_unTick = (uint)(1000 * Time.time);

            while (m_queue.Count != 0)
            {
                AbsTimerData p;
                lock (m_queueLock)
                    p = m_queue.Peek();
                if (m_unTick < p.UnNextTick)
                {
                    break;
                }
                lock (m_queueLock)
                    m_queue.Dequeue();
                if (p.NInterval > 0)
                {
                    p.UnNextTick += (ulong)p.NInterval;
                    lock (m_queueLock)
                        m_queue.Enqueue(p.NTimerId, p, p.UnNextTick);
                    p.DoAction();
                }
                else
                {
                    p.DoAction();
                }
            }
        }
Esempio n. 4
0
 public static void Tick()
 {
     mCurrentTick += (uint)mStopWatch.ElapsedMilliseconds;
     mStopWatch.Reset();
     mStopWatch.Start();
     while (mPriorityQueue.Count != 0)
     {
         TimerTask p;
         lock (mQueueLock)
         {
             p = mPriorityQueue.Peek();
         }
         if (mCurrentTick < p.NextTick)
         {
             break;
         }
         lock (mQueueLock)
         {
             mPriorityQueue.Dequeue();
         }
         if (p.Interval > 0)
         {
             p.NextTick += (ulong)p.Interval;
             lock (mQueueLock)
             {
                 mPriorityQueue.Enqueue(p.TimerId, p, p.NextTick);
             }
             p.DoAction();
         }
         else
         {
             p.DoAction();
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 周期调用触发任务
        /// </summary>
        public static void Tick()
        {
            m_unTick += (uint)(1000 * Time.deltaTime);
            //LoggerHelper.Error("m_unTick: " + (uint)(1000 * Time.deltaTime) + " Time.timeScale: " + Time.timeScale + " Time.deltaTime: " + Time.deltaTime);

            while (m_queue.Count != 0)
            {
                AbsTimerData p;
                lock (m_queueLock)
                    p = m_queue.Peek();
                if (m_unTick < p.UnNextTick)
                {
                    break;
                }
                lock (m_queueLock)
                    m_queue.Dequeue();
                if (p.NInterval > 0)
                {
                    p.UnNextTick += (ulong)p.NInterval;
                    lock (m_queueLock)
                        m_queue.Enqueue(p.NTimerId, p, p.UnNextTick);
                    p.DoAction();
                }
                else
                {
                    p.DoAction();
                }
            }
        }
Esempio n. 6
0
    static object Solve()
    {
        var(n, k) = Read2();
        var s = Console.ReadLine();

        var cs = new char[k];

        var q = new KeyedPriorityQueue <int, char>(i => s[i]);

        for (int i = 0; i < n - k; i++)
        {
            q.Push(i);
        }

        var t = -1;

        for (int i = n - k; i < n; i++)
        {
            q.Push(i);
            while (q.Peek() < t)
            {
                q.Pop();
            }

            t             = q.Pop();
            cs[i - n + k] = s[t];
        }

        return(new string(cs));
    }
Esempio n. 7
0
 public static void Tick()
 {
     m_unTick += (uint)(1000f * Time.get_deltaTime());
     while (m_queue.Count != 0)
     {
         AbsTimerData data;
         object       obj2;
         lock ((obj2 = m_queueLock))
         {
             data = m_queue.Peek();
         }
         if (m_unTick < data.UnNextTick)
         {
             break;
         }
         lock ((obj2 = m_queueLock))
         {
             m_queue.Dequeue();
         }
         if (data.NInterval > 0)
         {
             data.UnNextTick += data.NInterval;
             lock ((obj2 = m_queueLock))
             {
                 m_queue.Enqueue(data.NTimerId, data, data.UnNextTick);
             }
             data.DoAction();
         }
         else
         {
             data.DoAction();
         }
     }
 }
Esempio n. 8
0
 public static void Tick()
 {
     mCurrentTick += (uint)(1000 * Time.deltaTime);
     while (mPriorityQueue.Count != 0)
     {
         AbstractTimerData p;
         lock (mQueueLock)
             p = mPriorityQueue.Peek();
         if (mCurrentTick < p.mNextTick)
         {
             break;
         }
         lock (mQueueLock)
             mPriorityQueue.Dequeue();
         if (p.mInterval > 0)
         {
             p.mNextTick += (ulong)p.mInterval;
             lock (mQueueLock)
                 mPriorityQueue.Enqueue(p.mTimerId, p, p.mNextTick);
             p.DoAction();
         }
         else
         {
             p.DoAction();
         }
     }
 }
 override protected void OnStarted()
 {
     base.OnStarted();
     if (this.timerCallback != null)
     {
         lock (locker)
         {
             CallbackInfo ci = pendingScheduleRequests.Peek();
             if (ci != null)
             {
                 callbackTimer = CreateTimerCallback(ci);
             }
         }
     }
     lock (locker)
     {
         if (queueCounters == null && this.Runtime.PerformanceCounterManager != null)
         {
             queueCounters = this.Runtime.PerformanceCounterManager.CreateCounters(ExecutionStringManager.PerformanceCounterWorkflowsWaitingName);
         }
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 周期调用触发任务
        /// </summary>
        public static void Tick()
        {
            //累计获取逝去的时间
            m_unTick += (uint)m_stopWatch.ElapsedMilliseconds;
            //重置StopWatch
            m_stopWatch.Reset();
            m_stopWatch.Start();

            while (m_queue.Count != 0)
            {
                //队列出列
                AbsTimerData p;
                lock (m_queueLock)
                    p = m_queue.Peek();
                //判断出列Timer是否到时间
                if (m_unTick < p.UnNextTick)
                {
                    break;
                }
                //出列
                lock (m_queueLock)
                    m_queue.Dequeue();
                //间隔时间不等于0,重复执行Timer
                if (p.NInterval > 0)
                {
                    //更新下一次Tick时间
                    p.UnNextTick += (ulong)p.NInterval;
                    //重新入列
                    lock (m_queueLock)
                        m_queue.Enqueue(p.NTimerId, p, p.UnNextTick);
                    p.DoAction();
                }
                else
                {
                    p.DoAction();
                }
            }
        }
Esempio n. 11
0
 public static void Tick()
 {
     m_unTick += (uint)m_stopWatch.ElapsedMilliseconds;
     m_stopWatch.Reset();
     m_stopWatch.Start();
     while (m_queue.Count != 0)
     {
         AbsTimerData data;
         object       obj2;
         lock ((obj2 = m_queueLock))
         {
             data = m_queue.Peek();
         }
         if (m_unTick < data.UnNextTick)
         {
             break;
         }
         lock ((obj2 = m_queueLock))
         {
             m_queue.Dequeue();
         }
         if (data.NInterval > 0)
         {
             data.UnNextTick += data.NInterval;
             lock ((obj2 = m_queueLock))
             {
                 m_queue.Enqueue(data.NTimerId, data, data.UnNextTick);
             }
             data.DoAction();
         }
         else
         {
             data.DoAction();
         }
     }
 }
Esempio n. 12
0
    /// <summary>
    /// 周期调用触发任务
    /// </summary>
    public void Tick()
    {
        if (isPause)
        {
            return;
        }
        if (!m_stopWatch.IsRunning)
        {
            m_stopWatch.Start();
        }

        m_unTick = (uint)(UnityEngine.Time.time * 1000);

        m_checkTimeTmp       += m_invokeReaptingTime;
        m_timeSystemTimerTmp += m_invokeReaptingTime;
        if (m_cheat == false)
        {
            if (m_checkTimeTmp > m_checkPerTime)
            {
                m_checkTimeTmp = 0;
                CheckCheat();
            }
        }

        bool profilerSample = UnityEngine.Debug.isDebugBuild || UnityEngine.Application.isEditor;

        while (m_queue.Count != 0)
        {
            AbsTimerData p;
            lock (m_queueLock)
                p = m_queue.Peek();
            if (m_unTick < p.UnNextTick)
            {
                break;
            }
            lock (m_queueLock)
                m_queue.Dequeue();
            if (p.NInterval > 0)
            {
                p.UnNextTick += (ulong)p.NInterval;
                lock (m_queueLock)
                    m_queue.Enqueue(p.NTimerId, p, p.UnNextTick);
                if (profilerSample)
                {
                    var name = string.IsNullOrEmpty(p.StackTrack) ? p.Action.Method.Name : p.StackTrack;
                    Profiler.BeginSample(name);
                }
                p.DoAction();
                if (profilerSample)
                {
                    Profiler.EndSample();
                }
            }
            else
            {
                if (profilerSample)
                {
                    var name = string.IsNullOrEmpty(p.StackTrack) ? p.Action.Method.Name : p.StackTrack;
                    Profiler.BeginSample(name);
                }
                p.DoAction();
                if (profilerSample)
                {
                    Profiler.EndSample();
                }
            }
        }
    }