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