Esempio n. 1
0
        public void Tick()
        {
            if (wtState == WorkerStateInit)
            {
                wtState   = WorkerStateStarted;
                startTime = DateTime.Now;
            }
            if (wtState != WorkerStateStarted)
            {
                return;
            }

            TimeSpan currentDiff = DateTime.Now - startTime;

            long willTick_delta = currentDiff.Ticks / (tickInterval * 10000) - ticks;


            if (willTick_delta > 0)
            {
                for (long i = 0; i < willTick_delta; i++)
                {
                    int idx = (int)(this.ticks & this.mask);
                    //this.ProcessCancelledTasks();
                    HashedWheelSlot slot = this.wheel[idx];
                    slot.ExpireTimeouts();

                    //UnityEngine.Debug.Log("<color=yellow>" + idx.ToString() + "]</color>");
                    this.ticks++;
                }
            }
        }
Esempio n. 2
0
        internal void Remove()
        {
            HashedWheelSlot bucket = this.Slot;

            if (bucket != null)
            {
                // timeout got canceled before it was added to the bucket
                bucket.Remove(this);
            }
        }
Esempio n. 3
0
        static HashedWheelSlot[] CreateWheel(HashWheelTimer owner, int ticksPerWheel)
        {
            ticksPerWheel = NormalizeTicksPerWheel(ticksPerWheel);
            var wheel = new HashedWheelSlot[ticksPerWheel];

            for (int i = 0; i < wheel.Length; i++)
            {
                wheel[i] = new HashedWheelSlot(owner);
            }
            return(wheel);
        }