mirror of
https://github.com/KjellKod/g3log.git
synced 2024-12-12 10:23:50 +01:00
Time correction (#159)
* Improved the cpackage build. Also removed test compilation warnings * To correcte what was reported in issue 155 (https://github.com/KjellKod/g3log/issues/155)
This commit is contained in:
parent
417ae2ca10
commit
6e77118706
12
src/time.cpp
12
src/time.cpp
@ -99,9 +99,17 @@ namespace g3 {
|
||||
//
|
||||
// Time stamps will later have system clock accuracy but relative times will have the precision
|
||||
// of the high resolution clock.
|
||||
thread_local const auto os =
|
||||
time_point_cast<nanoseconds>(system_clock::now()).time_since_epoch() -
|
||||
thread_local const auto os_system =
|
||||
time_point_cast<nanoseconds>(system_clock::now()).time_since_epoch();
|
||||
thread_local const auto os_high_resolution =
|
||||
time_point_cast<nanoseconds>(high_resolution_clock::now()).time_since_epoch();
|
||||
thread_local auto os = os_system - os_high_resolution;
|
||||
|
||||
// 32-bit system work-around, where apparenetly the os correction above could sometimes
|
||||
// become negative. This correction will only be done once per thread
|
||||
if (os.count() < 0 ) {
|
||||
os = os_system;
|
||||
}
|
||||
|
||||
auto now_ns = (time_point_cast<nanoseconds>(high_resolution_clock::now()).time_since_epoch() + os).count();
|
||||
const auto kNanos = 1000000000;
|
||||
|
Loading…
Reference in New Issue
Block a user