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
174 listenPort = atoi(portStr);174 listenPort = atoi(portStr);
175 }175 }
176 176
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
177 // put the NodeList and datagram processing on the node thread183 // put the NodeList and datagram processing on the node thread
178 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);184 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
179 185
@@ -182,12 +188,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 2 unmodified lines
182 188
183 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal189 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
184 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), _datagramProcessor, SLOT(processDatagrams()));190 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();
191 191
192 // put the audio processing on a separate thread192 // put the audio processing on a separate thread
193 QThread* audioThread = new QThread(this);193 QThread* audioThread = new QThread(this);
@@ -236,7 +236,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 42 unmodified lines
236 nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));236 nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
237 237
238 // move the silentNodeTimer to the _nodeThread238 // move the silentNodeTimer to the _nodeThread
239 QTimer* silentNodeTimer = new QTimer(this);239 QTimer* silentNodeTimer = new QTimer();
240 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));240 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
241 silentNodeTimer->moveToThread(_nodeThread);241 silentNodeTimer->moveToThread(_nodeThread);
242 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);242 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
@@ -282,17 +282,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 39 unmodified lines
282Application::~Application() {282Application::~Application() {
283 283
284 qInstallMessageHandler(NULL);284 qInstallMessageHandler(NULL);
285 285
286 // make sure we don't call the idle timer any more286 // make sure we don't call the idle timer any more
287 delete idleTimer;287 delete idleTimer;
288 288
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
289 // ask the datagram processing thread to quit and wait until it is done297 // ask the datagram processing thread to quit and wait until it is done
290 _nodeThread->thread()->quit();298 _nodeThread->quit();
291 _nodeThread->thread()->wait();299 _nodeThread->wait();
292 300
293 // ask the audio thread to quit and wait until it is done301 // ask the audio thread to quit and wait until it is done
294 _audio.thread()->quit();302 _audio.thread()->quit();
295 _audio.thread()->wait();303 _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 }
296 314
297 storeSizeAndPosition();315 storeSizeAndPosition();
298 saveScripts();316 saveScripts();
@@ -377,9 +395,6 @@ void Application::initializeGL() { · 78 unmodified lines
377 qDebug("Voxel parsing thread created.");395 qDebug("Voxel parsing thread created.");
378 }396 }
379 397
380 // call terminate before exiting
381 connect(this, SIGNAL(aboutToQuit()), SLOT(terminate()));
382
383 // call our timer function every second398 // call our timer function every second
384 QTimer* timer = new QTimer(this);399 QTimer* timer = new QTimer(this);
385 connect(timer, SIGNAL(timeout()), SLOT(timer()));400 connect(timer, SIGNAL(timeout()), SLOT(timer()));
@@ -1412,28 +1427,6 @@ void Application::idle() { · 1026 unmodified lines
1412 }1427 }
1413}1428}
1414 1429
1415void 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
1437void Application::checkBandwidthMeterClick() {1430void Application::checkBandwidthMeterClick() {
1438 // ... to be called upon button release1431 // ... to be called upon button release
1439 1432

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