private void InitializeSlots() { slots = new HashedWheelSlot[WHEEL_BUCKETS, WHEEL_SIZE]; for (int i = 0; i != WHEEL_BUCKETS; ++i) { for (int j = 0; j != WHEEL_SIZE; ++j) { slots[i, j] = new HashedWheelSlot(); } } }
/// <summary> /// Reassign callback to higher precision timer slot. /// </summary> /// <param name="hierarchyIdx"></param> /// <param name="tick">lower 8 bits of current tick.</param> /// <returns></returns> private bool CascadeTimers(int hierarchyIdx, long tick) { // TODO // what if newly added timer has been assigned to cascading slot? var slot = new HashedWheelSlot(slots[hierarchyIdx, tick].Clear()); for (TimedCallback callback = slot.TryPop(); callback != null; callback = slot.TryPop()) { ScheduleTimeoutImpl(callback, callback.RemainingTime(time.Elapsed)); } return(tick == 0); }