mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 07:04:00 +02:00
Fix timestamp timer not fired
This commit is contained in:
parent
9884d74f60
commit
8b4a910040
5 changed files with 10 additions and 21 deletions
|
@ -17,8 +17,6 @@
|
||||||
#include "AssignmentClientMonitor.h"
|
#include "AssignmentClientMonitor.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
initialiseUsecTimestampNow();
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
#include "DomainServer.h"
|
#include "DomainServer.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
initialiseUsecTimestampNow();
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
int main(int argc, const char * argv[]) {
|
int main(int argc, const char * argv[]) {
|
||||||
initialiseUsecTimestampNow();
|
|
||||||
QElapsedTimer startupTime;
|
QElapsedTimer startupTime;
|
||||||
startupTime.start();
|
startupTime.start();
|
||||||
|
|
||||||
|
|
|
@ -30,27 +30,22 @@
|
||||||
#include "OctalCode.h"
|
#include "OctalCode.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
||||||
|
|
||||||
static qint64 TIME_REFERENCE = 0; // in usec
|
|
||||||
static QElapsedTimer timestampTimer;
|
|
||||||
static int usecTimestampNowAdjust = 0; // in usec
|
static int usecTimestampNowAdjust = 0; // in usec
|
||||||
|
|
||||||
void initialiseUsecTimestampNow() {
|
|
||||||
static bool initialised = false;
|
|
||||||
if (initialised) {
|
|
||||||
qDebug() << "[WARNING] Double initialisation of usecTimestampNow().";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * 1000; // ms to usec
|
|
||||||
initialised = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void usecTimestampNowForceClockSkew(int clockSkew) {
|
void usecTimestampNowForceClockSkew(int clockSkew) {
|
||||||
::usecTimestampNowAdjust = clockSkew;
|
::usecTimestampNowAdjust = clockSkew;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 usecTimestampNow() {
|
quint64 usecTimestampNow() {
|
||||||
|
static bool usecTimestampNowIsInitialized = false;
|
||||||
|
static qint64 TIME_REFERENCE = 0; // in usec
|
||||||
|
static QElapsedTimer timestampTimer;
|
||||||
|
|
||||||
|
if (!usecTimestampNowIsInitialized) {
|
||||||
|
TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * 1000; // ms to usec
|
||||||
|
timestampTimer.start();
|
||||||
|
usecTimestampNowIsInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
// usec nsec to usec usec
|
// usec nsec to usec usec
|
||||||
return TIME_REFERENCE + timestampTimer.nsecsElapsed() / 1000 + ::usecTimestampNowAdjust;
|
return TIME_REFERENCE + timestampTimer.nsecsElapsed() / 1000 + ::usecTimestampNowAdjust;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,6 @@ static const quint64 USECS_PER_SECOND = USECS_PER_MSEC * MSECS_PER_SECOND;
|
||||||
|
|
||||||
const int BITS_IN_BYTE = 8;
|
const int BITS_IN_BYTE = 8;
|
||||||
|
|
||||||
void initialiseUsecTimestampNow();
|
|
||||||
quint64 usecTimestampNow();
|
quint64 usecTimestampNow();
|
||||||
void usecTimestampNowForceClockSkew(int clockSkew);
|
void usecTimestampNowForceClockSkew(int clockSkew);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue