mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Merge pull request #8896 from ZappoMan/i5SandboxHeartbeat
actually make the RunningMarker run on a different thread
This commit is contained in:
commit
da0d1f1f13
2 changed files with 16 additions and 8 deletions
|
@ -19,7 +19,6 @@
|
||||||
#include "NumericalConstants.h"
|
#include "NumericalConstants.h"
|
||||||
#include "PathUtils.h"
|
#include "PathUtils.h"
|
||||||
|
|
||||||
|
|
||||||
RunningMarker::RunningMarker(QObject* parent, QString name) :
|
RunningMarker::RunningMarker(QObject* parent, QString name) :
|
||||||
_parent(parent),
|
_parent(parent),
|
||||||
_name(name)
|
_name(name)
|
||||||
|
@ -30,24 +29,28 @@ void RunningMarker::startRunningMarker() {
|
||||||
static const int RUNNING_STATE_CHECK_IN_MSECS = MSECS_PER_SECOND;
|
static const int RUNNING_STATE_CHECK_IN_MSECS = MSECS_PER_SECOND;
|
||||||
|
|
||||||
// start the nodeThread so its event loop is running
|
// start the nodeThread so its event loop is running
|
||||||
QThread* runningMarkerThread = new QThread(_parent);
|
_runningMarkerThread = new QThread(_parent);
|
||||||
runningMarkerThread->setObjectName("Running Marker Thread");
|
_runningMarkerThread->setObjectName("Running Marker Thread");
|
||||||
runningMarkerThread->start();
|
_runningMarkerThread->start();
|
||||||
|
|
||||||
writeRunningMarkerFiler(); // write the first file, even before timer
|
writeRunningMarkerFiler(); // write the first file, even before timer
|
||||||
|
|
||||||
QTimer* runningMarkerTimer = new QTimer(_parent);
|
_runningMarkerTimer = new QTimer();
|
||||||
QObject::connect(runningMarkerTimer, &QTimer::timeout, [=](){
|
QObject::connect(_runningMarkerTimer, &QTimer::timeout, [=](){
|
||||||
writeRunningMarkerFiler();
|
writeRunningMarkerFiler();
|
||||||
});
|
});
|
||||||
runningMarkerTimer->start(RUNNING_STATE_CHECK_IN_MSECS);
|
_runningMarkerTimer->start(RUNNING_STATE_CHECK_IN_MSECS);
|
||||||
|
|
||||||
// put the time on the thread
|
// put the time on the thread
|
||||||
runningMarkerTimer->moveToThread(runningMarkerThread);
|
_runningMarkerTimer->moveToThread(_runningMarkerThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
RunningMarker::~RunningMarker() {
|
RunningMarker::~RunningMarker() {
|
||||||
deleteRunningMarkerFile();
|
deleteRunningMarkerFile();
|
||||||
|
_runningMarkerTimer->stop();
|
||||||
|
_runningMarkerThread->quit();
|
||||||
|
_runningMarkerTimer->deleteLater();
|
||||||
|
_runningMarkerThread->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunningMarker::writeRunningMarkerFiler() {
|
void RunningMarker::writeRunningMarkerFiler() {
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
class QThread;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class RunningMarker {
|
class RunningMarker {
|
||||||
public:
|
public:
|
||||||
RunningMarker(QObject* parent, QString name);
|
RunningMarker(QObject* parent, QString name);
|
||||||
|
@ -30,6 +33,8 @@ protected:
|
||||||
|
|
||||||
QObject* _parent { nullptr };
|
QObject* _parent { nullptr };
|
||||||
QString _name;
|
QString _name;
|
||||||
|
QThread* _runningMarkerThread { nullptr };
|
||||||
|
QTimer* _runningMarkerTimer { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_RunningMarker_h
|
#endif // hifi_RunningMarker_h
|
||||||
|
|
Loading…
Reference in a new issue