mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +00:00
Use atomic primitives from standard library
QAtomicInteger underlying is using std::atomic structures, so using std::atomic directly should not be a problem for us. PR #19507.
This commit is contained in:
parent
270c63d64c
commit
d8a03cd8d8
@ -1274,7 +1274,7 @@ void Application::adjustThreadPriority() const
|
|||||||
void Application::cleanup()
|
void Application::cleanup()
|
||||||
{
|
{
|
||||||
// cleanup() can be called multiple times during shutdown. We only need it once.
|
// cleanup() can be called multiple times during shutdown. We only need it once.
|
||||||
if (!m_isCleanupRun.testAndSetAcquire(0, 1))
|
if (m_isCleanupRun.exchange(true, std::memory_order_acquire))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LogMsg(tr("qBittorrent termination initiated"));
|
LogMsg(tr("qBittorrent termination initiated"));
|
||||||
|
@ -30,8 +30,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include <QtSystemDetection>
|
#include <QtSystemDetection>
|
||||||
#include <QAtomicInt>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -177,7 +178,7 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ApplicationInstanceManager *m_instanceManager = nullptr;
|
ApplicationInstanceManager *m_instanceManager = nullptr;
|
||||||
QAtomicInt m_isCleanupRun;
|
std::atomic_bool m_isCleanupRun;
|
||||||
bool m_isProcessingParamsAllowed = false;
|
bool m_isProcessingParamsAllowed = false;
|
||||||
ShutdownDialogAction m_shutdownAct = ShutdownDialogAction::Exit;
|
ShutdownDialogAction m_shutdownAct = ShutdownDialogAction::Exit;
|
||||||
QBtCommandLineParameters m_commandLineArgs;
|
QBtCommandLineParameters m_commandLineArgs;
|
||||||
|
@ -93,12 +93,12 @@ void TorrentCreator::checkInterruptionRequested() const
|
|||||||
|
|
||||||
void TorrentCreator::requestInterruption()
|
void TorrentCreator::requestInterruption()
|
||||||
{
|
{
|
||||||
m_interruptionRequested.storeRelaxed(1);
|
m_interruptionRequested.store(true, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TorrentCreator::isInterruptionRequested() const
|
bool TorrentCreator::isInterruptionRequested() const
|
||||||
{
|
{
|
||||||
return m_interruptionRequested.loadRelaxed() != 0;
|
return m_interruptionRequested.load(std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentCreator::run()
|
void TorrentCreator::run()
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAtomicInt>
|
#include <atomic>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRunnable>
|
#include <QRunnable>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -96,6 +97,6 @@ namespace BitTorrent
|
|||||||
void checkInterruptionRequested() const;
|
void checkInterruptionRequested() const;
|
||||||
|
|
||||||
TorrentCreatorParams m_params;
|
TorrentCreatorParams m_params;
|
||||||
QAtomicInt m_interruptionRequested;
|
std::atomic_bool m_interruptionRequested;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user