mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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")
|
||||
{
|
||||
connect(&m_updateTimer, &QTimer::timeout, this, &CBackgroundDataUpdater::doWork);
|
||||
}
|
||||
|
||||
void CBackgroundDataUpdater::initialize()
|
||||
{
|
||||
m_updateTimer.start(60 * 1000);
|
||||
}
|
||||
|
||||
void CBackgroundDataUpdater::cleanup()
|
||||
{
|
||||
m_updateTimer.stop();
|
||||
m_shutdown = true;
|
||||
m_enabled = false;
|
||||
}
|
||||
|
||||
CBackgroundDataUpdater::~CBackgroundDataUpdater()
|
||||
{
|
||||
gracefulShutdown();
|
||||
@@ -60,18 +71,12 @@ namespace BlackCore
|
||||
|
||||
void CBackgroundDataUpdater::gracefulShutdown()
|
||||
{
|
||||
if (m_shutdown) { return; }
|
||||
m_shutdown = true;
|
||||
m_enabled = false;
|
||||
if (!CThreadUtils::isCurrentThreadObjectThread(this))
|
||||
{
|
||||
this->abandonAndWait();
|
||||
}
|
||||
else
|
||||
{
|
||||
// timer needs to be stopped in its own thread
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CBackgroundDataUpdater::startUpdating(int updateTimeSecs)
|
||||
|
||||
@@ -38,6 +38,12 @@ namespace BlackCore
|
||||
//! Destructor
|
||||
virtual ~CBackgroundDataUpdater();
|
||||
|
||||
//! \copydoc BlackMisc::CContinuousWorker::initialize
|
||||
virtual void initialize() override;
|
||||
|
||||
//! \copydoc BlackMisc::CContinuousWorker::cleanup
|
||||
virtual void cleanup() override;
|
||||
|
||||
//! Is shutting down?
|
||||
//! \threadsafe
|
||||
bool isShuttingDown() const;
|
||||
|
||||
Reference in New Issue
Block a user