eve.core.timer
Types 2
structTimerWheel
Hierarchical timing wheel for efficient timer management.
- O(1) insert, O(1) cancel, O(1) amortized expiration check.
- Granularity: 1ms (tick).
- Range: ~18 hours (4 levels).
- No dynamic allocations (uses pre-allocated entries from watcher slots).
Fields
1 TICK_MSInitial tick duration (base granularity).8 LEVEL0_BITSLevel 0 configuration (256 slots).1 << LEVEL0_BITS LEVEL0_SIZELEVEL0_SIZE - 1 LEVEL0_MASK6 LEVELN_BITSHigher levels configuration (64 slots each).1 << LEVELN_BITS LEVELN_SIZELEVELN_SIZE - 1 LEVELN_MASK4 NUM_LEVELSTotal number of levels.LEVEL0_SIZE + (NUM_LEVELS - 1) * LEVELN_SIZE TOTAL_SLOTSTotal number of slots across all levels.Slot[TOTAL_SLOTS] _allSlotsFixed-size array of slots for all levels.uint[NUM_LEVELS] _offsetsOffsets into `allSlots` for each level.long _currentTickMonotonic tick counter advancing 1ms at a time.size_t _activeCountTotal number of active timers in the wheel.Methods
size_t count() @property const pure @safe nothrow @nogcReturn the total number of active timers in the wheel.void schedule(long delayMs, Entry * entry) @safe nothrow @nogcSchedule a timer entry in the appropriate level and slot.int nextDeadlineMs() const pure @safe nothrow @nogcReturn the number of milliseconds until the next timer is scheduled to fire.long currentTick() @property const pure @safe nothrow @nogcReport the current monotonic tick counter.Nested Templates
EntryIntrusive node for the timing wheel's linked lists.SlotInfostructTimerSpec
Declarative timer configuration stored by the loop.
Fields
long delayMsInitial delay before the first firing, in milliseconds.long intervalMsRepeating interval in milliseconds. `0` means one-shot.Methods
bool repeating() @property const pure @safe nothrow @nogcReport whether the timer repeats after the first firing.Functions 2
fn
long normalizedDelay(long value) pure @safe nothrow @nogcClamp a requested timer delay to the non-negative range accepted by the loop.fn
long normalizedInterval(long value) pure @safe nothrow @nogcClamp a requested timer interval to the non-negative range accepted by the loop.