/** \brief Load a new simulation * * Load a new simulation. Be aware that you must free the ressource of * the old simulation, if it exists, before calling this function. */ void MainController::load_configuration(QString& file) { mSimulationFilePath = file; mSimulator = new sim::NBody(sim::RK4); std::ifstream in_stream(file.toUtf8().data()); mSimulator->lire_valeurs(in_stream); const std::vector<sim::Body>& bodies = mSimulator->getCorps(); for(std::vector<sim::Body>::const_iterator it = bodies.begin(); it != bodies.end(); it++) { eng::Planet* p = eng::PlanetFactory::getPlanet("earth"); mEngine->addPlanet(&(*it), p); } mSimulationThread = new SimulatorThread(*this); connect(mSimulationThread, SIGNAL(resultReady()), this, SIGNAL(model_updated())); connect(mSimulationThread, SIGNAL(finished()), this, SLOT(thread_finished())); setState(INITIALIZED); }
//--------------------------------------------------------- // Launch the secondary thread in which the Python interpreter // is executed, since this call comes from the main Application thread. // void Tart::start() { if (m_thread) return; QSemaphore sem(0); // qDebug() << QThread::currentThreadId() << "Tart: starting TartThread"; m_thread = new TartThread(&sem); this->moveToThread(m_thread); m_thread->start(); connect(m_thread, SIGNAL(finished()), this, SLOT(thread_finished())); // being able to acquire this semaphore means the Python main thread // has succesfully started, and qDebug() << QThread::currentThreadId() << "Tart: wait for sema"; sem.acquire(1); qDebug() << QThread::currentThreadId() << "Tart: got sema"; // Only make the connection here if the interpreter entered the event loop. if (m_thread->ran_loop()) { // force postMessage() to result in a QueuedConnection for now // since the default doesn't appear to be picking the right method // TODO: investigate if that's a sign of a problem connect(this, SIGNAL(postMessage(QString)), this, SLOT(do_postMessage(QString)), Qt::QueuedConnection); } }
/* Called after a thread has performed its last memory access. */ static void drd_thread_finished(ThreadId vg_tid) { DrdThreadId drd_tid; tl_assert(VG_(get_running_tid)() == vg_tid); drd_tid = VgThreadIdToDrdThreadId(vg_tid); if (s_drd_trace_fork_join) { VG_(message)(Vg_DebugMsg, "drd_thread_finished tid = %d/%d%s", vg_tid, drd_tid, thread_get_joinable(drd_tid) ? "" : " (which is a detached thread)"); } if (s_show_stack_usage) { const SizeT stack_size = thread_get_stack_size(drd_tid); const SizeT used_stack = thread_get_stack_max(drd_tid) - thread_get_stack_min_min(drd_tid); VG_(message)(Vg_UserMsg, "thread %d/%d%s finished and used %ld bytes out of %ld" " on its stack. Margin: %ld bytes.", vg_tid, drd_tid, thread_get_joinable(drd_tid) ? "" : " (which is a detached thread)", used_stack, stack_size, stack_size - used_stack); } drd_stop_using_mem(thread_get_stack_min(drd_tid), thread_get_stack_max(drd_tid) - thread_get_stack_min(drd_tid), True); thread_stop_recording(drd_tid); thread_finished(drd_tid); }