mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
Added functions to test usleep, msleep and sleep for accuracy.
This commit is contained in:
parent
3c42e31b4f
commit
3fbde70f96
1 changed files with 11 additions and 7 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include "OctalCode.h"
|
#include "OctalCode.h"
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
@ -415,13 +416,16 @@ void printVoxelCode(unsigned char* voxelCode) {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void usleep(int waitTime) {
|
void usleep(int waitTime) {
|
||||||
__int64 time1 = 0, time2 = 0, sysFreq = 0;
|
quint64 compTime = waitTime + usecTimestampNow();
|
||||||
|
quint64 compTimeSleep = compTime - 2000;
|
||||||
QueryPerformanceCounter((LARGE_INTEGER *)&time1);
|
while (true) {
|
||||||
QueryPerformanceFrequency((LARGE_INTEGER *)&sysFreq);
|
if (usecTimestampNow() < compTimeSleep) {
|
||||||
do {
|
QThread::msleep(1);
|
||||||
QueryPerformanceCounter((LARGE_INTEGER *)&time2);
|
}
|
||||||
} while( (time2 - time1) < waitTime);
|
if (usecTimestampNow() >= compTime) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue