本文整理汇总了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;
}
示例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);
}
}