예제 #1
0
파일: Timer.cs 프로젝트: zhizhen/thewar
    void Add(int deadline, Timer tm)
    {
        tm.deadline = deadline;
        int   delay         = Math.Max(0, deadline - now());
        Wheel suitableWheel = wheels [3];

        for (int i = 0; i < wheels.Length; i++)
        {
            var wheel = wheels [i];
            if (delay <= wheel.time_limit)
            {
                suitableWheel = wheel;
                break;
            }
        }
        suitableWheel.Add(delay, tm);
    }
예제 #2
0
        public static void InnerAdd(int deadline, Timer tm)
        {
            tm.Deadline = deadline;
            int   delay         = Math.Max(0, deadline - Now());
            Wheel suitableWheel = Wheels[Wheels.Length - 1];

            for (int i = 0; i < Wheels.Length; ++i)
            {
                Wheel wheel = Wheels[i];
                if (delay < wheel.TimeRange)
                {
                    suitableWheel = wheel;
                    break;
                }
            }

            suitableWheel.Add(delay, tm);
        }