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
TICK_MSInitial tick duration (base granularity). LEVEL0_BITSLevel 0 configuration (256 slots). LEVEL0_SIZE LEVEL0_MASK LEVELN_BITSHigher levels configuration (64 slots each). LEVELN_SIZE LEVELN_MASK NUM_LEVELSTotal number of levels. TOTAL_SLOTSTotal number of slots across all levels.private Slot[TOTAL_SLOTS] _allSlotsFixed-size array of slots for all levels.private uint[NUM_LEVELS] _offsetsOffsets into `allSlots` for each level.private long _currentTickMonotonic tick counter advancing 1ms at a time.private size_t _activeCountTotal number of active timers in the wheel.private ulong[4] _level0BitsBitmap of non-empty level-0 slots (256 bits = 4 × ulong).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.SlotA slot in the wheel — head and tail of a doubly-linked list of entries.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.