From f2936e0e081de82dedf5f437f84d99debea49027 Mon Sep 17 00:00:00 2001 From: dec05eba <0xdec05eba@gmail.com> Date: Wed, 25 Apr 2018 06:00:13 +0200 Subject: Improve database startup by moving timestamp sync to where it's needed --- src/Database.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Database.cpp b/src/Database.cpp index 383cc18..d4ae190 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -132,11 +132,6 @@ namespace odhtdb if(ntpThread->joinable()) ntpThread->detach(); } - - while(!timestampSynced) - { - this_thread::sleep_for(10ms); - } } Database::~Database() @@ -438,7 +433,10 @@ namespace odhtdb ntp::NtpTimestamp Database::getSyncedTimestampUtc() const { - assert(timestampSynced); + while(!timestampSynced) + { + this_thread::sleep_for(10ms); + } ntp::NtpTimestamp timestamp; timestamp.seconds = time(nullptr) - timeOffset; timestamp.fractions = 0; // TODO: Set this -- cgit v1.2.3