From 8841ea78fd3386118c7514c89c22fae057cc151a Mon Sep 17 00:00:00 2001 From: dec05eba 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(-) (limited to 'src') 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