mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Revert "NOT MERGEABLE: graceful cleanup on Application dtor for NodeList"
This commit is contained in:
parent
4da9186045
commit
9269b2a0b2
6 changed files with 34 additions and 27 deletions
|
@ -267,6 +267,10 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
|
||||||
connect(nodeList.data(), &LimitedNodeList::nodeAdded, this, &DomainServer::nodeAdded);
|
connect(nodeList.data(), &LimitedNodeList::nodeAdded, this, &DomainServer::nodeAdded);
|
||||||
connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &DomainServer::nodeKilled);
|
connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &DomainServer::nodeKilled);
|
||||||
|
|
||||||
|
QTimer* silentNodeTimer = new QTimer(this);
|
||||||
|
connect(silentNodeTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
|
||||||
|
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
|
||||||
|
|
||||||
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readAvailableDatagrams()));
|
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readAvailableDatagrams()));
|
||||||
|
|
||||||
// add whatever static assignments that have been parsed to the queue
|
// add whatever static assignments that have been parsed to the queue
|
||||||
|
|
|
@ -146,6 +146,7 @@ const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB
|
||||||
|
|
||||||
static QTimer* locationUpdateTimer = NULL;
|
static QTimer* locationUpdateTimer = NULL;
|
||||||
static QTimer* balanceUpdateTimer = NULL;
|
static QTimer* balanceUpdateTimer = NULL;
|
||||||
|
static QTimer* silentNodeTimer = NULL;
|
||||||
static QTimer* identityPacketTimer = NULL;
|
static QTimer* identityPacketTimer = NULL;
|
||||||
static QTimer* billboardPacketTimer = NULL;
|
static QTimer* billboardPacketTimer = NULL;
|
||||||
static QTimer* checkFPStimer = NULL;
|
static QTimer* checkFPStimer = NULL;
|
||||||
|
@ -257,6 +258,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_dependencyManagerIsSetup(setupEssentials(argc, argv)),
|
_dependencyManagerIsSetup(setupEssentials(argc, argv)),
|
||||||
_window(new MainWindow(desktop())),
|
_window(new MainWindow(desktop())),
|
||||||
_toolWindow(NULL),
|
_toolWindow(NULL),
|
||||||
|
_nodeThread(new QThread(this)),
|
||||||
_datagramProcessor(),
|
_datagramProcessor(),
|
||||||
_undoStack(),
|
_undoStack(),
|
||||||
_undoStackScriptingInterface(&_undoStack),
|
_undoStackScriptingInterface(&_undoStack),
|
||||||
|
@ -327,20 +329,18 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
||||||
|
|
||||||
// start the nodeThread so its event loop is running
|
// start the nodeThread so its event loop is running
|
||||||
QThread* nodeThread = new QThread(this);
|
_nodeThread->setObjectName("Datagram Processor Thread");
|
||||||
nodeThread->setObjectName("Datagram Processor Thread");
|
_nodeThread->start();
|
||||||
nodeThread->start();
|
|
||||||
|
|
||||||
// make sure the node thread is given highest priority
|
// make sure the node thread is given highest priority
|
||||||
nodeThread->setPriority(QThread::TimeCriticalPriority);
|
_nodeThread->setPriority(QThread::TimeCriticalPriority);
|
||||||
|
|
||||||
_datagramProcessor = new DatagramProcessor(nodeList.data());
|
|
||||||
|
|
||||||
// put the NodeList and datagram processing on the node thread
|
// put the NodeList and datagram processing on the node thread
|
||||||
nodeList->moveToThread(nodeThread);
|
nodeList->moveToThread(_nodeThread);
|
||||||
|
_datagramProcessor.moveToThread(_nodeThread);
|
||||||
|
|
||||||
// connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
|
// connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
|
||||||
connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, _datagramProcessor, &DatagramProcessor::processDatagrams);
|
connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
|
||||||
|
|
||||||
// put the audio processing on a separate thread
|
// put the audio processing on a separate thread
|
||||||
QThread* audioThread = new QThread();
|
QThread* audioThread = new QThread();
|
||||||
|
@ -427,6 +427,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
// connect to the packet sent signal of the _entityEditSender
|
// connect to the packet sent signal of the _entityEditSender
|
||||||
connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
|
connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
|
||||||
|
|
||||||
|
// move the silentNodeTimer to the _nodeThread
|
||||||
|
silentNodeTimer = new QTimer();
|
||||||
|
connect(silentNodeTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
|
||||||
|
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
|
||||||
|
silentNodeTimer->moveToThread(_nodeThread);
|
||||||
|
|
||||||
// send the identity packet for our avatar each second to our avatar mixer
|
// send the identity packet for our avatar each second to our avatar mixer
|
||||||
identityPacketTimer = new QTimer();
|
identityPacketTimer = new QTimer();
|
||||||
connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
|
connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
|
||||||
|
@ -541,7 +547,7 @@ void Application::aboutToQuit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::cleanupBeforeQuit() {
|
void Application::cleanupBeforeQuit() {
|
||||||
_datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
|
_datagramProcessor.shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
|
||||||
_entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
|
_entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
|
||||||
ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
|
ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
|
||||||
|
|
||||||
|
@ -549,6 +555,7 @@ void Application::cleanupBeforeQuit() {
|
||||||
// depending on what thread they run in
|
// depending on what thread they run in
|
||||||
locationUpdateTimer->stop();
|
locationUpdateTimer->stop();
|
||||||
balanceUpdateTimer->stop();
|
balanceUpdateTimer->stop();
|
||||||
|
QMetaObject::invokeMethod(silentNodeTimer, "stop", Qt::BlockingQueuedConnection);
|
||||||
identityPacketTimer->stop();
|
identityPacketTimer->stop();
|
||||||
billboardPacketTimer->stop();
|
billboardPacketTimer->stop();
|
||||||
checkFPStimer->stop();
|
checkFPStimer->stop();
|
||||||
|
@ -558,6 +565,7 @@ void Application::cleanupBeforeQuit() {
|
||||||
// and then delete those that got created by "new"
|
// and then delete those that got created by "new"
|
||||||
delete locationUpdateTimer;
|
delete locationUpdateTimer;
|
||||||
delete balanceUpdateTimer;
|
delete balanceUpdateTimer;
|
||||||
|
delete silentNodeTimer;
|
||||||
delete identityPacketTimer;
|
delete identityPacketTimer;
|
||||||
delete billboardPacketTimer;
|
delete billboardPacketTimer;
|
||||||
delete checkFPStimer;
|
delete checkFPStimer;
|
||||||
|
@ -589,6 +597,10 @@ Application::~Application() {
|
||||||
tree->lockForWrite();
|
tree->lockForWrite();
|
||||||
_entities.getTree()->setSimulation(NULL);
|
_entities.getTree()->setSimulation(NULL);
|
||||||
tree->unlock();
|
tree->unlock();
|
||||||
|
|
||||||
|
// ask the datagram processing thread to quit and wait until it is done
|
||||||
|
_nodeThread->quit();
|
||||||
|
_nodeThread->wait();
|
||||||
|
|
||||||
_octreeProcessor.terminate();
|
_octreeProcessor.terminate();
|
||||||
_entityEditSender.terminate();
|
_entityEditSender.terminate();
|
||||||
|
@ -608,14 +620,6 @@ Application::~Application() {
|
||||||
DependencyManager::destroy<GeometryCache>();
|
DependencyManager::destroy<GeometryCache>();
|
||||||
//DependencyManager::destroy<ScriptCache>();
|
//DependencyManager::destroy<ScriptCache>();
|
||||||
DependencyManager::destroy<SoundCache>();
|
DependencyManager::destroy<SoundCache>();
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
QThread* nodeThread = nodeList->thread();
|
|
||||||
nodeList->deleteLater();
|
|
||||||
|
|
||||||
// ask the node thread to quit and wait until it is done
|
|
||||||
nodeThread->quit();
|
|
||||||
nodeThread->wait();
|
|
||||||
|
|
||||||
qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
|
qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1498,7 @@ void Application::checkFPS() {
|
||||||
|
|
||||||
_fps = (float)_frameCount / diffTime;
|
_fps = (float)_frameCount / diffTime;
|
||||||
_frameCount = 0;
|
_frameCount = 0;
|
||||||
_datagramProcessor->resetCounters();
|
_datagramProcessor.resetCounters();
|
||||||
_timerStart.start();
|
_timerStart.start();
|
||||||
|
|
||||||
// ask the node list to check in with the domain server
|
// ask the node list to check in with the domain server
|
||||||
|
|
|
@ -445,8 +445,10 @@ private:
|
||||||
MainWindow* _window;
|
MainWindow* _window;
|
||||||
|
|
||||||
ToolWindow* _toolWindow;
|
ToolWindow* _toolWindow;
|
||||||
|
|
||||||
DatagramProcessor* _datagramProcessor;
|
|
||||||
|
QThread* _nodeThread;
|
||||||
|
DatagramProcessor _datagramProcessor;
|
||||||
|
|
||||||
QUndoStack _undoStack;
|
QUndoStack _undoStack;
|
||||||
UndoStackScriptingInterface _undoStackScriptingInterface;
|
UndoStackScriptingInterface _undoStackScriptingInterface;
|
||||||
|
|
|
@ -80,10 +80,6 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
|
||||||
connect(localSocketUpdate, &QTimer::timeout, this, &LimitedNodeList::updateLocalSockAddr);
|
connect(localSocketUpdate, &QTimer::timeout, this, &LimitedNodeList::updateLocalSockAddr);
|
||||||
localSocketUpdate->start(LOCAL_SOCKET_UPDATE_INTERVAL_MSECS);
|
localSocketUpdate->start(LOCAL_SOCKET_UPDATE_INTERVAL_MSECS);
|
||||||
|
|
||||||
QTimer* silentNodeTimer = new QTimer(this);
|
|
||||||
connect(silentNodeTimer, &QTimer::timeout, this, &LimitedNodeList::removeSilentNodes);
|
|
||||||
silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
|
|
||||||
|
|
||||||
// check the local socket right now
|
// check the local socket right now
|
||||||
updateLocalSockAddr();
|
updateLocalSockAddr();
|
||||||
|
|
||||||
|
@ -504,7 +500,6 @@ void LimitedNodeList::resetPacketStats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::removeSilentNodes() {
|
void LimitedNodeList::removeSilentNodes() {
|
||||||
|
|
||||||
QSet<SharedNodePointer> killedNodes;
|
QSet<SharedNodePointer> killedNodes;
|
||||||
|
|
||||||
eachNodeHashIterator([&](NodeHash::iterator& it){
|
eachNodeHashIterator([&](NodeHash::iterator& it){
|
||||||
|
|
|
@ -223,8 +223,6 @@ protected:
|
||||||
HifiSockAddr _localSockAddr;
|
HifiSockAddr _localSockAddr;
|
||||||
HifiSockAddr _publicSockAddr;
|
HifiSockAddr _publicSockAddr;
|
||||||
HifiSockAddr _stunSockAddr;
|
HifiSockAddr _stunSockAddr;
|
||||||
|
|
||||||
QTimer* _silentNodeTimer;
|
|
||||||
|
|
||||||
// XXX can BandwidthRecorder be used for this?
|
// XXX can BandwidthRecorder be used for this?
|
||||||
int _numCollectedPackets;
|
int _numCollectedPackets;
|
||||||
|
|
|
@ -67,6 +67,10 @@ void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeTy
|
||||||
connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
|
connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit()));
|
||||||
domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
|
domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
|
||||||
|
|
||||||
|
QTimer* silentNodeRemovalTimer = new QTimer(this);
|
||||||
|
connect(silentNodeRemovalTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
|
||||||
|
silentNodeRemovalTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
|
||||||
|
|
||||||
if (shouldSendStats) {
|
if (shouldSendStats) {
|
||||||
// send a stats packet every 1 second
|
// send a stats packet every 1 second
|
||||||
QTimer* statsTimer = new QTimer(this);
|
QTimer* statsTimer = new QTimer(this);
|
||||||
|
|
Loading…
Reference in a new issue