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); }
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); }