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


C++ QAtomicInt::testAndSetAcquire方法代码示例

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


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

示例1: setup

void MfSession::setup()
{
    if (!setupInProgress.testAndSetAcquire(0, 1)) {
        // If a session setup is in progress wait some time
        QTimer::singleShot(10, this, SLOT(setup()));
        return;
    }

    MfManager *manager = MfManager::instance();
    QVector<QStringList> feedbackDirLists = getFeedbackDirLists(manager->currentTheme(), appName);
    QStringList feedbackDirs;

    for (int i = 0; i < feedbackDirLists.size(); ++i) {
        feedbackDirs << feedbackDirLists[i][0];
    }

    if (feedbackDirLists.isEmpty()) {
        // Can't live without feedbacks
        qFatal("It is not possible to load any feedbacks.");
    }

    // Map the feedbacks
    foreach (const QStringList& feedbackDirList, feedbackDirLists) {
        MfFeedback *feedback = new MfFeedback(this);
        feedback->load(feedbackDirList);
        feedbackHash[feedback->name()] = feedback;
    }
开发者ID:dudochkin-victor,项目名称:touch-feedback,代码行数:27,代码来源:mfsession.cpp

示例2: cleanup

void Application::cleanup()
{
    // cleanup() can be called multiple times during shutdown. We only need it once.
    static QAtomicInt alreadyDone;
    if (!alreadyDone.testAndSetAcquire(0, 1))
        return;

#ifndef DISABLE_GUI
    if (m_window) {
        // Hide the window and don't leave it on screen as
        // unresponsive. Also for Windows take the WinId
        // after it's hidden, because hide() may cause a
        // WinId change.
        m_window->hide();

#ifdef Q_OS_WIN
        typedef BOOL (WINAPI *PSHUTDOWNBRCREATE)(HWND, LPCWSTR);
        const auto shutdownBRCreate = Utils::Misc::loadWinAPI<PSHUTDOWNBRCREATE>("User32.dll", "ShutdownBlockReasonCreate");
        // Only available on Vista+
        if (shutdownBRCreate)
            shutdownBRCreate((HWND)m_window->effectiveWinId(), tr("Saving torrent progress...").toStdWString().c_str());
#endif // Q_OS_WIN

        // Do manual cleanup in MainWindow to force widgets
        // to save their Preferences, stop all timers and
        // delete as many widgets as possible to leave only
        // a 'shell' MainWindow.
        // We need a valid window handle for Windows Vista+
        // otherwise the system shutdown will continue even
        // though we created a ShutdownBlockReason
        m_window->cleanup();
    }
#endif // DISABLE_GUI

#ifndef DISABLE_WEBUI
    delete m_webui;
#endif

    delete RSS::AutoDownloader::instance();
    delete RSS::Session::instance();

    ScanFoldersModel::freeInstance();
    BitTorrent::Session::freeInstance();
#ifndef DISABLE_COUNTRIES_RESOLUTION
    Net::GeoIPManager::freeInstance();
#endif
    Net::DownloadManager::freeInstance();
    Net::ProxyConfigurationManager::freeInstance();
    Preferences::freeInstance();
    SettingsStorage::freeInstance();
    delete m_fileLogger;
    Logger::freeInstance();
    IconProvider::freeInstance();
    SearchPluginManager::freeInstance();
    Utils::Fs::removeDirRecursive(Utils::Fs::tempPath());

#ifndef DISABLE_GUI
    if (m_window) {
#ifdef Q_OS_WIN
        typedef BOOL (WINAPI *PSHUTDOWNBRDESTROY)(HWND);
        const auto shutdownBRDestroy = Utils::Misc::loadWinAPI<PSHUTDOWNBRDESTROY>("User32.dll", "ShutdownBlockReasonDestroy");
        // Only available on Vista+
        if (shutdownBRDestroy)
            shutdownBRDestroy((HWND)m_window->effectiveWinId());
#endif // Q_OS_WIN
        delete m_window;
    }
#endif // DISABLE_GUI

    if (m_shutdownAct != ShutdownDialogAction::Exit) {
        qDebug() << "Sending computer shutdown/suspend/hibernate signal...";
        Utils::Misc::shutdownComputer(m_shutdownAct);
    }
}
开发者ID:suratovvlad,项目名称:qBittorrent,代码行数:74,代码来源:application.cpp


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