mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 20:06:02 +02:00
Update persistInterval to use std::chrono in OctreePersistThread
This commit is contained in:
parent
8f4f3db9ce
commit
d0af06939f
4 changed files with 17 additions and 12 deletions
|
@ -1050,8 +1050,13 @@ void OctreeServer::readConfiguration() {
|
||||||
_persistAsFileType = "json.gz";
|
_persistAsFileType = "json.gz";
|
||||||
|
|
||||||
_persistInterval = OctreePersistThread::DEFAULT_PERSIST_INTERVAL;
|
_persistInterval = OctreePersistThread::DEFAULT_PERSIST_INTERVAL;
|
||||||
readOptionInt(QString("persistInterval"), settingsSectionObject, _persistInterval);
|
int result { -1 };
|
||||||
qDebug() << "persistInterval=" << _persistInterval;
|
readOptionInt(QString("persistInterval"), settingsSectionObject, result);
|
||||||
|
if (result != -1) {
|
||||||
|
_persistInterval = std::chrono::seconds(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "persistInterval=" << _persistInterval.count();
|
||||||
|
|
||||||
readOptionBool(QString("persistFileDownload"), settingsSectionObject, _persistFileDownload);
|
readOptionBool(QString("persistFileDownload"), settingsSectionObject, _persistFileDownload);
|
||||||
qDebug() << "persistFileDownload=" << _persistFileDownload;
|
qDebug() << "persistFileDownload=" << _persistFileDownload;
|
||||||
|
|
|
@ -193,7 +193,7 @@ protected:
|
||||||
OctreePersistThread* _persistManager;
|
OctreePersistThread* _persistManager;
|
||||||
QThread _persistThread;
|
QThread _persistThread;
|
||||||
|
|
||||||
int _persistInterval;
|
std::chrono::milliseconds _persistInterval;
|
||||||
bool _persistFileDownload;
|
bool _persistFileDownload;
|
||||||
int _maxBackupVersions;
|
int _maxBackupVersions;
|
||||||
|
|
||||||
|
|
|
@ -36,13 +36,12 @@
|
||||||
#include "OctreeUtils.h"
|
#include "OctreeUtils.h"
|
||||||
#include "OctreeDataUtils.h"
|
#include "OctreeDataUtils.h"
|
||||||
|
|
||||||
const int OctreePersistThread::DEFAULT_PERSIST_INTERVAL { 1000 * 30 }; // every 30 seconds
|
const std::chrono::seconds OctreePersistThread::DEFAULT_PERSIST_INTERVAL { 30 };
|
||||||
|
|
||||||
constexpr int MAX_OCTREE_REPLACEMENT_BACKUP_FILES_COUNT { 20 };
|
constexpr int MAX_OCTREE_REPLACEMENT_BACKUP_FILES_COUNT { 20 };
|
||||||
//constexpr int MAX_OCTREE_REPLACEMENT_BACKUP_FILES_SIZE_BYTES { 50 * 1000 * 1000 };
|
constexpr size_t MAX_OCTREE_REPLACEMENT_BACKUP_FILES_SIZE_BYTES { 50 * 1000 * 1000 };
|
||||||
constexpr size_t MAX_OCTREE_REPLACEMENT_BACKUP_FILES_SIZE_BYTES { 70000 };
|
|
||||||
|
|
||||||
OctreePersistThread::OctreePersistThread(OctreePointer tree, const QString& filename, int persistInterval,
|
OctreePersistThread::OctreePersistThread(OctreePointer tree, const QString& filename, std::chrono::milliseconds persistInterval,
|
||||||
bool debugTimestampNow, QString persistAsFileType) :
|
bool debugTimestampNow, QString persistAsFileType) :
|
||||||
_tree(tree),
|
_tree(tree),
|
||||||
_filename(filename),
|
_filename(filename),
|
||||||
|
@ -187,7 +186,8 @@ void OctreePersistThread::handleOctreeDataFileReply(QSharedPointer<ReceivedMessa
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Starting timer";
|
qDebug() << "Starting timer";
|
||||||
QTimer::singleShot(_persistInterval, this, &OctreePersistThread::process);
|
QTimer::singleShot(std::chrono::milliseconds(_persistInterval).count(), this, &OctreePersistThread::process);
|
||||||
|
QTimer::singleShot(std::chrono::milliseconds(1000).count(), this, &OctreePersistThread::process);
|
||||||
|
|
||||||
emit loadCompleted();
|
emit loadCompleted();
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ bool OctreePersistThread::process() {
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
quint64 sinceLastSave = now - _lastCheck;
|
quint64 sinceLastSave = now - _lastCheck;
|
||||||
quint64 intervalToCheck = _persistInterval * MSECS_TO_USECS;
|
quint64 intervalToCheck = std::chrono::microseconds(_persistInterval).count();
|
||||||
|
|
||||||
if (sinceLastSave > intervalToCheck) {
|
if (sinceLastSave > intervalToCheck) {
|
||||||
_lastCheck = now;
|
_lastCheck = now;
|
||||||
|
|
|
@ -30,11 +30,11 @@ public:
|
||||||
quint64 lastBackup;
|
quint64 lastBackup;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int DEFAULT_PERSIST_INTERVAL;
|
static const std::chrono::seconds DEFAULT_PERSIST_INTERVAL;
|
||||||
|
|
||||||
OctreePersistThread(OctreePointer tree,
|
OctreePersistThread(OctreePointer tree,
|
||||||
const QString& filename,
|
const QString& filename,
|
||||||
int persistInterval = DEFAULT_PERSIST_INTERVAL,
|
std::chrono::milliseconds persistInterval = DEFAULT_PERSIST_INTERVAL,
|
||||||
bool debugTimestampNow = false,
|
bool debugTimestampNow = false,
|
||||||
QString persistAsFileType = "json.gz");
|
QString persistAsFileType = "json.gz");
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
OctreePointer _tree;
|
OctreePointer _tree;
|
||||||
QString _filename;
|
QString _filename;
|
||||||
int _persistInterval;
|
std::chrono::milliseconds _persistInterval;
|
||||||
bool _initialLoadComplete;
|
bool _initialLoadComplete;
|
||||||
|
|
||||||
quint64 _loadTimeUSecs;
|
quint64 _loadTimeUSecs;
|
||||||
|
|
Loading…
Reference in a new issue