Ejemplo n.º 1
0
        public TimerManager()
        {
            for (int i = 0; i < 5; i++)
            {
                timerWheels[i] = new TimerListWheel();
            }

            UInt64 now = TickerContext.GetTick();

            timerWheels[0].Init(1, 0, null, timerWheels[1], now);
            timerWheels[1].Init(0xff + 1, 8, timerWheels[0], timerWheels[2], now);
            timerWheels[2].Init(0xffff + 1, 16, timerWheels[1], timerWheels[3], now);
            timerWheels[3].Init(0xffffff + 1, 24, timerWheels[2], timerWheels[4], now);
            timerWheels[4].Init((UInt64)0xffffffff + 1, 32, timerWheels[3], null, now);
        }
Ejemplo n.º 2
0
        protected Timer CreateTimer(int delay, Timer.TimerCallback op, bool loop, params object[] parameters)
        {
            uint seqID = GetSeqID();

            delay = delay < 0 ? 0 : delay;
            UInt64 run_tick = TickerContext.GetTick() + (UInt64)delay;

            if (run_tick > 0x000000ffffffffff)
            {
                run_tick = run_tick & 0x000000ffffffffff;
            }

            Timer newTimer = new Timer();

            newTimer.seqID      = seqID;
            newTimer.runTick    = run_tick;
            newTimer.delay      = delay;
            newTimer.callback   = op;
            newTimer.parameters = parameters;
            newTimer.timerID    = (run_tick << 24) | (seqID & 0xffffff);
            return(newTimer);
        }
Ejemplo n.º 3
0
        public bool Execute(int maxCount)
        {
            UInt64 now = TickerContext.GetTick();

            return(timerWheels[0].Execute(now, ref maxCount));
        }