当前位置: 首页>>代码示例>>C++>>正文


C++ QThread::wait方法代码示例

本文整理汇总了C++中QThread::wait方法的典型用法代码示例。如果您正苦于以下问题:C++ QThread::wait方法的具体用法?C++ QThread::wait怎么用?C++ QThread::wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QThread的用法示例。


在下文中一共展示了QThread::wait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

void WaitThread::run()
{
    thread1->wait();
    thread2->wait();

    qApp->lock();
    label->setText("<h1>Done!</h1>");
    qApp->unlock();
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:9,代码来源:main.cpp

示例2: databaseThreaded

void tst_QDjango::databaseThreaded()
{
    if (QDjango::database().databaseName() == QLatin1String(":memory:"))
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
        QSKIP("Threaded test cannot work with in-memory SQLite database.");
#else
        QSKIP("Threaded test cannot work with in-memory SQLite database.", SkipAll);
#endif

    QDjangoQuerySet<Author> qs;
    QCOMPARE(qs.count(), 0);

    QEventLoop loop;
    Worker worker;
    QThread workerThread;

    // fire up worker
    worker.moveToThread(&workerThread);
    connect(&worker, SIGNAL(done()), &loop, SLOT(quit()));

    workerThread.start();
    QTimer::singleShot(0, &worker, SLOT(doIt()));
    loop.exec();

    // check database
    QCOMPARE(qs.count(), 1);

    // stop thread
    workerThread.quit();
    workerThread.wait();
}
开发者ID:Dem0n3D,项目名称:qdjango,代码行数:31,代码来源:tst_qdjango.cpp

示例3: debuger_exec

    DEBUGER_EXPORT int debuger_exec(int (*fn)(int, char**), void (*exit_fn)()) {
        if (fn) {
            debuger_thread_runner runner(fn, app_argc, app_argv);
            debuger_thread_actor actor;
            QThread child;

            QObject::connect(&actor, SIGNAL(start()), &runner, SLOT(start()));
            QObject::connect(&runner, SIGNAL(finished()), &actor, SLOT(finished()));

            runner.moveToThread(&child);
            child.start();
            actor.start();

            int ret = debuger::app->exec();

            if (exit_fn)
                exit_fn();

            // ==== child join
            child.quit();
            child.wait();
            return ret;
        }

        return debuger::app->exec();
    }
开发者ID:owt5008137,项目名称:client-debuger,代码行数:26,代码来源:main.cpp

示例4: exec

int ServerApp::exec()
{
    QThread appThread;

    m_impl->application.moveToThread(&appThread);
    appThread.start();

    m_impl->window.show();

    // ... and run
    // Qt event loop must be in the main thread
    boost::thread orbThread(
        boost::bind(&CORBA::ORB::run, m_impl->orb.in()));

    int res = m_impl->app.exec();

    appThread.quit();
    appThread.wait();

    m_impl->orb->shutdown(1);

    orbThread.join();

    delete m_impl;
    m_impl = NULL;

    return res;
}
开发者ID:cetium,项目名称:corbasim,代码行数:28,代码来源:ServerApp.cpp

示例5: cleanup

void QNetworkConfigurationManagerPrivate::cleanup()
{
    QThread* thread = bearerThread;
    deleteLater();
    if (thread->wait(5000))
        delete thread;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:7,代码来源:qnetworkconfigmanager_p.cpp

示例6: main

int main(int argc, char* argv[])
{
#ifdef Q_WS_X11
  QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#endif

  QGuiApplication app(argc,argv);
  SettingsRef     settings;
  MainWindow      *window;
  int             result;

  app.setOrganizationName("libosmscout");
  app.setOrganizationDomain("libosmscout.sf.net");
  app.setApplicationName("OSMScout");

  settings=new Settings();

  //qRegisterMetaType<RenderMapRequest>();
  qRegisterMetaType<DatabaseLoadedResponse>();

  qmlRegisterType<MapWidget>("net.sf.libosmscout.map", 1, 0, "Map");
  qmlRegisterType<Location>("net.sf.libosmscout.map", 1, 0, "Location");
  qmlRegisterType<LocationListModel>("net.sf.libosmscout.map", 1, 0, "LocationListModel");
  qmlRegisterType<RouteStep>("net.sf.libosmscout.map", 1, 0, "RouteStep");
  qmlRegisterType<RoutingListModel>("net.sf.libosmscout.map", 1, 0, "RoutingListModel");

  qmlRegisterSingletonType<Theme>("net.sf.libosmscout.map", 1, 0, "Theme", ThemeProvider);

  QThread thread;

  if (!DBThread::InitializeInstance()) {
    std::cerr << "Cannot initialize DBThread" << std::endl;
  }

  DBThread* dbThread=DBThread::GetInstance();

  window=new MainWindow(settings,
                        dbThread);
  window->resize(480,800);
  window->setResizeMode(QQuickView::SizeRootObjectToView);

  dbThread->connect(&thread, SIGNAL(started()), SLOT(Initialize()));
  dbThread->connect(&thread, SIGNAL(finished()), SLOT(Finalize()));

  dbThread->moveToThread(&thread);
  thread.start();

  window->show();

  result=app.exec();

  delete window;

  thread.quit();
  thread.wait();

  DBThread::FreeInstance();

  return result;
}
开发者ID:LamaUrbain,项目名称:libosmscout,代码行数:60,代码来源:OSMScout.cpp

示例7: moveToThread

void tst_QTimer::moveToThread()
{
    QTimer ti1;
    QTimer ti2;
    ti1.start(MOVETOTHREAD_TIMEOUT);
    ti2.start(MOVETOTHREAD_TIMEOUT);
    QVERIFY((ti1.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff));
    QThread tr;
    ti1.moveToThread(&tr);
    connect(&ti1,SIGNAL(timeout()), &tr, SLOT(quit()));
    tr.start();
    QTimer ti3;
    ti3.start(MOVETOTHREAD_TIMEOUT);
    QVERIFY((ti3.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff));
    QVERIFY((ti3.timerId() & 0xffffff) != (ti1.timerId() & 0xffffff));
    QTest::qWait(MOVETOTHREAD_WAIT);
    QVERIFY(tr.wait());
    ti2.stop();
    QTimer ti4;
    ti4.start(MOVETOTHREAD_TIMEOUT);
    ti3.stop();
    ti2.start(MOVETOTHREAD_TIMEOUT);
    ti3.start(MOVETOTHREAD_TIMEOUT);
    QVERIFY((ti4.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff));
    QVERIFY((ti3.timerId() & 0xffffff) != (ti2.timerId() & 0xffffff));
    QVERIFY((ti3.timerId() & 0xffffff) != (ti1.timerId() & 0xffffff));
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:27,代码来源:tst_qtimer.cpp

示例8: main

int main(int argc, char* argv[])
{
#ifdef Q_WS_X11
    QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#endif

    QGuiApplication app(argc,argv);
    SettingsRef     settings;
    MainWindow      *window;
    int             result;

    app.setOrganizationName("libosmscout");
    app.setOrganizationDomain("libosmscout.sf.net");
    app.setApplicationName("OSMScout");

    settings=std::make_shared<Settings>();

    qRegisterMetaType<RenderMapRequest>();
    qRegisterMetaType<DatabaseLoadedResponse>();
    qRegisterMetaType<osmscout::TileRef>();

    qmlRegisterType<MapWidget>("net.sf.libosmscout.map", 1, 0, "Map");
    qmlRegisterType<Location>("net.sf.libosmscout.map", 1, 0, "Location");
    qmlRegisterType<LocationListModel>("net.sf.libosmscout.map", 1, 0, "LocationListModel");
    qmlRegisterType<FileIO, 1>("FileIO", 1, 0, "FileIO");

    QThread thread;

    if (!DBThread::InitializeInstance(/*settings*/)) {
        std::cerr << "Cannot initialize DBThread" << std::endl;
    }

    DBThread* dbThread=DBThread::GetInstance();

    window=new MainWindow(settings,
                          dbThread);

    dbThread->connect(&thread, SIGNAL(started()), SLOT(Initialize()));
    dbThread->connect(&thread, SIGNAL(finished()), SLOT(Finalize()));

    dbThread->moveToThread(&thread);
    thread.start();

    result=app.exec();

    delete window;

    QString tmpStylesheet(dbThread->GetStylesheetFilename()+TMP_SUFFIX);
    if(QFile::exists(tmpStylesheet)) {
        QFile::remove(tmpStylesheet);
    }

    thread.quit();
    thread.wait();

    DBThread::FreeInstance();

    return result;
}
开发者ID:OgreTransporter,项目名称:libosmscout,代码行数:59,代码来源:StyleEditor.cpp

示例9: waitForProcessingThread

/**
 * This prevents deadlock which happens when the processing thread tries to create new MidiSession while the main thread is waiting for it to terminate.
 * The cause is that creating MidiSession blocks the processing thread and invokes corresponding slot of Master in its thread as required.
 * On the other hand, stop() is usually called in the main thread - the thread of Master. So, we attempt to unblock
 * by processing posted QEvent::MetaCall events directed to Master.
 */
void MidiDriver::waitForProcessingThread(QThread &thread, MasterClockNanos timeout) {
	while (!thread.wait(timeout / MasterClock::NANOS_PER_MILLISECOND)) {
		Master *master = Master::getInstance();
		if (QThread::currentThread() == master->thread()) {
			QCoreApplication::sendPostedEvents(master, QEvent::MetaCall);
		}
	}
}
开发者ID:polluks,项目名称:munt,代码行数:14,代码来源:MidiDriver.cpp

示例10: main

int main(int argc, char* argv[])
{
#ifdef Q_WS_X11
  QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
#endif

  QGuiApplication app(argc,argv);
  SettingsRef     settings;
  int             result;

  app.setOrganizationName("libosmscout");
  app.setOrganizationDomain("libosmscout.sf.net");
  app.setApplicationName("OSMScout");

  qRegisterMetaType<RenderMapRequest>();
  qRegisterMetaType<DatabaseLoadedResponse>();
  qRegisterMetaType<osmscout::TileRef>();

  qmlRegisterType<MapWidget>("net.sf.libosmscout.map", 1, 0, "Map");
  qmlRegisterType<Location>("net.sf.libosmscout.map", 1, 0, "Location");
  qmlRegisterType<LocationListModel>("net.sf.libosmscout.map", 1, 0, "LocationListModel");
  qmlRegisterType<RouteStep>("net.sf.libosmscout.map", 1, 0, "RouteStep");
  qmlRegisterType<RoutingListModel>("net.sf.libosmscout.map", 1, 0, "RoutingListModel");

  qmlRegisterSingletonType<Theme>("net.sf.libosmscout.map", 1, 0, "Theme", ThemeProvider);

  osmscout::log.Debug(true);

  settings=std::make_shared<Settings>();

  QThread thread;

  if (!DBThread::InitializeInstance()) {
    std::cerr << "Cannot initialize DBThread" << std::endl;
    return 1;
  }

  DBThread* dbThread=DBThread::GetInstance();

  dbThread->connect(&thread, SIGNAL(started()), SLOT(Initialize()));
  dbThread->connect(&thread, SIGNAL(finished()), SLOT(Finalize()));

  dbThread->moveToThread(&thread);

  QQmlApplicationEngine window(QUrl("qrc:/qml/main.qml"));

  thread.start();

  result=app.exec();

  thread.quit();
  thread.wait();

  DBThread::FreeInstance();

  return result;
}
开发者ID:OgreTransporter,项目名称:libosmscout,代码行数:57,代码来源:OSMScout.cpp

示例11: thread

Servatrice_GameServer::~Servatrice_GameServer()
{
    for (int i = 0; i < connectionPools.size(); ++i) {
        logger->logMessage(QString("Closing pool %1...").arg(i));
        QThread *poolThread = connectionPools[i]->thread();
        connectionPools[i]->deleteLater(); // pool destructor calls thread()->quit()
        poolThread->wait();
    }
}
开发者ID:Aurenos,项目名称:Cockatrice,代码行数:9,代码来源:servatrice.cpp

示例12:

AssignmentClient::~AssignmentClient() {
    QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
    
    // remove the NodeList from the DependencyManager
    DependencyManager::destroy<NodeList>();

    // ask the node thread to quit and wait until it is done
    nodeThread->quit();
    nodeThread->wait();
}
开发者ID:AlexanderOtavka,项目名称:hifi,代码行数:10,代码来源:AssignmentClient.cpp

示例13:

ThreadHandle::~ThreadHandle() //停止所有线程,并释放资源
{
    QThread * tmp;
    for (auto it = threadSize.begin(); it != threadSize.end(); ++it)
    {
        tmp = it.key();
        tmp->exit();
        tmp->wait(3000);
        delete tmp;
    }
}
开发者ID:ProChen,项目名称:QtTcpThreadServer,代码行数:11,代码来源:threadhandle.cpp

示例14: cleanupPrivateInstance

 // cleans up the settings private instance. Should only be run once at closing down.
 void cleanupPrivateInstance() {
     // grab the thread before we nuke the instance
     QThread* settingsManagerThread = privateInstance->thread();
     
     // tell the private instance to clean itself up on its thread
     privateInstance->deleteLater();
     privateInstance = NULL;
     
     // quit the settings manager thread and wait on it to make sure it's gone
     settingsManagerThread->quit();
     settingsManagerThread->wait();
 }
开发者ID:,项目名称:,代码行数:13,代码来源:

示例15: waitForThreadCompletion

int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
{
    Q_ASSERT(threadID);

    QThread* thread = threadForIdentifier(threadID);

    bool res = thread->wait();

    clearThreadForIdentifier(threadID);
    if (result)
        *result = static_cast<ThreadPrivate*>(thread)->getReturnValue();

    return !res;
}
开发者ID:fluxer,项目名称:katie,代码行数:14,代码来源:ThreadingQt.cpp


注:本文中的QThread::wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。