mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 03:15:34 +08:00
T66 Tidying up CBackgroundDataUpdater startup and shutdown
by overriding the CContinuousWorker virtual methods that exist for this purpose.
This commit is contained in:
@@ -37,9 +37,20 @@ namespace BlackCore
|
|||||||
CContinuousWorker(owner, "Background data updater")
|
CContinuousWorker(owner, "Background data updater")
|
||||||
{
|
{
|
||||||
connect(&m_updateTimer, &QTimer::timeout, this, &CBackgroundDataUpdater::doWork);
|
connect(&m_updateTimer, &QTimer::timeout, this, &CBackgroundDataUpdater::doWork);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBackgroundDataUpdater::initialize()
|
||||||
|
{
|
||||||
m_updateTimer.start(60 * 1000);
|
m_updateTimer.start(60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBackgroundDataUpdater::cleanup()
|
||||||
|
{
|
||||||
|
m_updateTimer.stop();
|
||||||
|
m_shutdown = true;
|
||||||
|
m_enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
CBackgroundDataUpdater::~CBackgroundDataUpdater()
|
CBackgroundDataUpdater::~CBackgroundDataUpdater()
|
||||||
{
|
{
|
||||||
gracefulShutdown();
|
gracefulShutdown();
|
||||||
@@ -60,18 +71,12 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CBackgroundDataUpdater::gracefulShutdown()
|
void CBackgroundDataUpdater::gracefulShutdown()
|
||||||
{
|
{
|
||||||
if (m_shutdown) { return; }
|
|
||||||
m_shutdown = true;
|
m_shutdown = true;
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
if (!CThreadUtils::isCurrentThreadObjectThread(this))
|
if (!CThreadUtils::isCurrentThreadObjectThread(this))
|
||||||
{
|
{
|
||||||
this->abandonAndWait();
|
this->abandonAndWait();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// timer needs to be stopped in its own thread
|
|
||||||
m_updateTimer.stop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBackgroundDataUpdater::startUpdating(int updateTimeSecs)
|
void CBackgroundDataUpdater::startUpdating(int updateTimeSecs)
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ namespace BlackCore
|
|||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CBackgroundDataUpdater();
|
virtual ~CBackgroundDataUpdater();
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
||||||
|
virtual void initialize() override;
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::CContinuousWorker::cleanup
|
||||||
|
virtual void cleanup() override;
|
||||||
|
|
||||||
//! Is shutting down?
|
//! Is shutting down?
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
bool isShuttingDown() const;
|
bool isShuttingDown() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user