ExampleSearch::~ExampleSearch() { // Stop queuemanager thread if (m_queueThread->isRunning()) { m_queueThread->disconnect(); m_queueThread->quit(); m_queueThread->wait(); } // Delete queuemanager delete m_queue; m_queue = 0; #ifdef ENABLE_SSH // Stop SSHManager delete m_ssh; m_ssh = 0; #endif // ENABLE_SSH // Wait for save to finish while (savePending) { qDebug() << "Spinning on save before destroying ExampleSearch..."; GS_SLEEP(1); }; savePending = true; // Clean up various members m_initWC->deleteLater(); m_initWC = 0; }
QueueManager::~QueueManager() { m_isDestroying = true; this->disconnect(); // Wait for handler trackers to empty. QList<Tracker*> trackers; trackers.append(&m_newlyOptimizedTracker); trackers.append(&m_stepOptimizedTracker); trackers.append(&m_inProcessTracker); trackers.append(&m_errorTracker); trackers.append(&m_submittedTracker); trackers.append(&m_newlyKilledTracker); trackers.append(&m_newDuplicateTracker); trackers.append(&m_newSupercellTracker); trackers.append(&m_restartTracker); trackers.append(&m_newSubmissionTracker); // Used to break wait loops if they take too long unsigned int timeout; for (QList<Tracker *>::iterator it = trackers.begin(), it_end = trackers.end(); it != it_end; it++) { timeout = 10; while (timeout > 0 && (*it)->size()) { qDebug() << "Spinning on QueueManager handler trackers to empty..."; GS_SLEEP(1); --timeout; } } // Wait for m_requestedStructures to == 0 timeout = 15; while (timeout > 0 && m_requestedStructures > 0) { qDebug() << "Waiting for structure generation threads to finish..."; GS_SLEEP(1); --timeout; } delete m_lastSubmissionTimeStamp; }