64-bit millisecond timer - returns milliseconds since system startup without wraparound
This function provides a 64-bit millisecond counter that never wraps around in any practical timeframe (584 million years). It's built on top of fl::millis() and automatically detects and corrects for 32-bit wraparound.
The implementation uses a function-local static for thread-safe accumulation on platforms that support it. On platforms with native 64-bit timers, this function may be optimized to use the native implementation directly.
- Returns
- Number of milliseconds since system startup as a 64-bit value
- Note
- Thread-safe on platforms with proper static initialization guards
-
No wraparound in practical usage (584+ million years)
-
Slightly higher overhead than millis() due to wraparound detection
Examples
long_running_operation();
log_event("operation_complete", event_time);
fl::u64 millis64()
64-bit millisecond timer - returns milliseconds since system startup without wraparound
Definition at line 108 of file chrono.cpp.hpp.
108 {
109 Millis64State&
state = get_millis64_state();
111 fl::unique_lock<fl::mutex> lock(
state.mutex);
112
113 if (!
state.initialized) {
114
115 state.accumulated = current_millis;
116 state.last_millis = current_millis;
117 state.initialized =
true;
118 return state.accumulated;
119 }
120
121
122
123 fl::u32 delta = current_millis -
state.last_millis;
124
125
126 state.accumulated += delta;
127
128
129 state.last_millis = current_millis;
130
131 return state.accumulated;
132}
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
References millis(), millis64(), and state.
Referenced by millis64(), and time().