mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 03:23:33 +02:00
implement aboutToFinish for persist thread to allow final save before shutdown
This commit is contained in:
parent
edc599bc2d
commit
11058355a0
4 changed files with 33 additions and 14 deletions
|
@ -1197,6 +1197,9 @@ void OctreeServer::aboutToFinish() {
|
||||||
qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node;
|
qDebug() << qPrintable(_safeServerName) << "server about to finish while node still connected node:" << *node;
|
||||||
forceNodeShutdown(node);
|
forceNodeShutdown(node);
|
||||||
}
|
}
|
||||||
|
if (_persistThread) {
|
||||||
|
_persistThread->aboutToFinish();
|
||||||
|
}
|
||||||
qDebug() << qPrintable(_safeServerName) << "server ENDING about to finish...";
|
qDebug() << qPrintable(_safeServerName) << "server ENDING about to finish...";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1089,7 +1089,6 @@ bool DebugOperator::preRecursion(OctreeElement* element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::dumpTree() {
|
void EntityTree::dumpTree() {
|
||||||
// First, look for the existing entity in the tree..
|
|
||||||
DebugOperator theOperator;
|
DebugOperator theOperator;
|
||||||
recurseTreeWithOperator(&theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1106,6 @@ bool PruneOperator::postRecursion(OctreeElement* element) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTree::pruneTree() {
|
void EntityTree::pruneTree() {
|
||||||
// First, look for the existing entity in the tree..
|
|
||||||
PruneOperator theOperator;
|
PruneOperator theOperator;
|
||||||
recurseTreeWithOperator(&theOperator);
|
recurseTreeWithOperator(&theOperator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,19 +78,33 @@ bool OctreePersistThread::process() {
|
||||||
quint64 intervalToCheck = _persistInterval * MSECS_TO_USECS;
|
quint64 intervalToCheck = _persistInterval * MSECS_TO_USECS;
|
||||||
|
|
||||||
if (sinceLastSave > intervalToCheck) {
|
if (sinceLastSave > intervalToCheck) {
|
||||||
// check the dirty bit and persist here...
|
_lastCheck = now;
|
||||||
_lastCheck = usecTimestampNow();
|
persistOperation();
|
||||||
if (_tree->isDirty()) {
|
|
||||||
qDebug() << "pruning Octree before saving...";
|
|
||||||
_tree->pruneTree();
|
|
||||||
qDebug() << "DONE pruning Octree before saving...";
|
|
||||||
|
|
||||||
qDebug() << "saving Octree to file " << _filename << "...";
|
|
||||||
_tree->writeToSVOFile(_filename.toLocal8Bit().constData());
|
|
||||||
_tree->clearDirtyBit(); // tree is clean after saving
|
|
||||||
qDebug("DONE saving Octree to file...");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isStillRunning(); // keep running till they terminate us
|
return isStillRunning(); // keep running till they terminate us
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void OctreePersistThread::aboutToFinish() {
|
||||||
|
qDebug() << "Persist thread about to finish...";
|
||||||
|
persistOperation();
|
||||||
|
qDebug() << "Persist thread done with about to finish...";
|
||||||
|
}
|
||||||
|
|
||||||
|
void OctreePersistThread::persistOperation() {
|
||||||
|
if (_tree->isDirty()) {
|
||||||
|
_tree->lockForWrite();
|
||||||
|
{
|
||||||
|
qDebug() << "pruning Octree before saving...";
|
||||||
|
_tree->pruneTree();
|
||||||
|
qDebug() << "DONE pruning Octree before saving...";
|
||||||
|
}
|
||||||
|
_tree->unlock();
|
||||||
|
|
||||||
|
qDebug() << "saving Octree to file " << _filename << "...";
|
||||||
|
_tree->writeToSVOFile(_filename.toLocal8Bit().constData());
|
||||||
|
_tree->clearDirtyBit(); // tree is clean after saving
|
||||||
|
qDebug("DONE saving Octree to file...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -29,12 +29,16 @@ public:
|
||||||
bool isInitialLoadComplete() const { return _initialLoadComplete; }
|
bool isInitialLoadComplete() const { return _initialLoadComplete; }
|
||||||
quint64 getLoadElapsedTime() const { return _loadTimeUSecs; }
|
quint64 getLoadElapsedTime() const { return _loadTimeUSecs; }
|
||||||
|
|
||||||
|
void aboutToFinish(); /// call this to inform the persist thread that the owner is about to finish to support final persist
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loadCompleted();
|
void loadCompleted();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Implements generic processing behavior for this thread.
|
/// Implements generic processing behavior for this thread.
|
||||||
virtual bool process();
|
virtual bool process();
|
||||||
|
|
||||||
|
void persistOperation();
|
||||||
private:
|
private:
|
||||||
Octree* _tree;
|
Octree* _tree;
|
||||||
QString _filename;
|
QString _filename;
|
||||||
|
|
Loading…
Reference in a new issue