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 172 of file chrono.cpp.hpp.
172 {
173 Millis64State&
state = get_millis64_state();
175 fl::unique_lock<fl::mutex> lock(
state.mutex);
176
177 if (!
state.initialized) {
178
179 state.accumulated = current_millis;
180 state.last_millis = current_millis;
181 state.initialized =
true;
182 return state.accumulated;
183 }
184
185
186
187 fl::u32 delta = current_millis -
state.last_millis;
188
189
190 state.accumulated += delta;
191
192
193 state.last_millis = current_millis;
194
195 return state.accumulated;
196}
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
References millis(), millis64(), and state.
Referenced by millis64(), and time().