aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <0xdec05eba@gmail.com>2018-04-25 06:00:13 +0200
committerdec05eba <0xdec05eba@gmail.com>2018-04-25 06:00:18 +0200
commitf2936e0e081de82dedf5f437f84d99debea49027 (patch)
treebfec5159ae85e2bc382e30cf0512dbf37403a73c
parentd71fe129b83f34b46136070fcf9a64865203be14 (diff)
Improve database startup by moving timestamp sync to where it's needed
-rw-r--r--src/Database.cpp10
1 files 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