History

more nodelist repairs for concurrency issues

Stephen Birarda committed 12 years ago

Commit b5a72ef1 parent 04286e34 files · +37 −41Browse files

Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all

Unified · Split

interface/src/Application.cpp+29−36
@@ -174,6 +174,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 173 unmodified lines
174174 listenPort = atoi(portStr);
175175 }
176176
177+ // start the nodeThread so its event loop is running
178+ _nodeThread->start();
179+
180+ // make sure the node thread is given highest priority
181+ _nodeThread->setPriority(QThread::TimeCriticalPriority);
182+
177183 // put the NodeList and datagram processing on the node thread
178184 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
179185
@@ -182,12 +188,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 2 unmodified lines
182188
183189 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
184190 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), _datagramProcessor, SLOT(processDatagrams()));
185−
186− // make sure the node thread is given highest priority
187− _nodeThread->setPriority(QThread::TimeCriticalPriority);
188−
189− // start the nodeThread so its event loop is running
190− _nodeThread->start();
191191
192192 // put the audio processing on a separate thread
193193 QThread* audioThread = new QThread(this);
@@ -236,7 +236,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 42 unmodified lines
236236 nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
237237
238238 // move the silentNodeTimer to the _nodeThread
239− QTimer* silentNodeTimer = new QTimer(this);
239+ QTimer* silentNodeTimer = new QTimer();
240240 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
241241 silentNodeTimer->moveToThread(_nodeThread);
242242 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
@@ -282,17 +282,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 39 unmodified lines
282282 Application::~Application() {
283283
284284 qInstallMessageHandler(NULL);
285−
285+
286286 // make sure we don't call the idle timer any more
287287 delete idleTimer;
288288
289+ Menu::getInstance()->saveSettings();
290+
291+ _rearMirrorTools->saveSettings(_settings);
292+ _settings->sync();
293+
294+ // let the avatar mixer know we're out
295+ NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
296+
289297 // ask the datagram processing thread to quit and wait until it is done
290− _nodeThread->thread()->quit();
291− _nodeThread->thread()->wait();
292−
298+ _nodeThread->quit();
299+ _nodeThread->wait();
300+
293301 // ask the audio thread to quit and wait until it is done
294302 _audio.thread()->quit();
295303 _audio.thread()->wait();
304+
305+ _voxelProcessor.terminate();
306+ _voxelHideShowThread.terminate();
307+ _voxelEditSender.terminate();
308+ _particleEditSender.terminate();
309+ if (_persistThread) {
310+ _persistThread->terminate();
311+ _persistThread->deleteLater();
312+ _persistThread = NULL;
313+ }
296314
297315 storeSizeAndPosition();
298316 saveScripts();
@@ -377,9 +395,6 @@ void Application::initializeGL() { · 78 unmodified lines
377395 qDebug("Voxel parsing thread created.");
378396 }
379397
380− // call terminate before exiting
381− connect(this, SIGNAL(aboutToQuit()), SLOT(terminate()));
382−
383398 // call our timer function every second
384399 QTimer* timer = new QTimer(this);
385400 connect(timer, SIGNAL(timeout()), SLOT(timer()));
@@ -1412,28 +1427,6 @@ void Application::idle() { · 1026 unmodified lines
14121427 }
14131428 }
14141429
1415−void Application::terminate() {
1416− // Close serial port
1417− // close(serial_fd);
1418−
1419− Menu::getInstance()->saveSettings();
1420− _rearMirrorTools->saveSettings(_settings);
1421− _settings->sync();
1422−
1423− // let the avatar mixer know we're out
1424− NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
1425−
1426− _voxelProcessor.terminate();
1427− _voxelHideShowThread.terminate();
1428− _voxelEditSender.terminate();
1429− _particleEditSender.terminate();
1430− if (_persistThread) {
1431− _persistThread->terminate();
1432− _persistThread->deleteLater();
1433− _persistThread = NULL;
1434− }
1435−}
1436−
14371430 void Application::checkBandwidthMeterClick() {
14381431 // ... to be called upon button release
14391432

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t