mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
DB reader, doWorkCheck before writing cache. In case shutdown takes place in-between.
This commit is contained in:
@@ -215,6 +215,7 @@ namespace BlackCore
|
||||
Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
const int size = airports.size();
|
||||
qint64 latestTimestamp = airports.latestTimestampMsecsSinceEpoch();
|
||||
if (size > 0 && latestTimestamp < 0)
|
||||
|
||||
@@ -292,6 +292,7 @@ namespace BlackCore
|
||||
Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
const int n = codes.size();
|
||||
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch(); // ignores duplicates
|
||||
if (n > 0 && latestTimestamp < 0)
|
||||
@@ -342,6 +343,7 @@ namespace BlackCore
|
||||
Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
const int n = codes.size();
|
||||
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch();
|
||||
if (n > 0 && latestTimestamp < 0)
|
||||
@@ -382,6 +384,7 @@ namespace BlackCore
|
||||
countries = CCountryList::fromDatabaseJson(res);
|
||||
}
|
||||
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
const int n = countries.size();
|
||||
qint64 latestTimestamp = countries.latestTimestampMsecsSinceEpoch();
|
||||
if (n > 0 && latestTimestamp < 0)
|
||||
|
||||
@@ -301,6 +301,7 @@ namespace BlackCore
|
||||
liveries = CLiveryList::fromDatabaseJson(res);
|
||||
}
|
||||
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
const int n = liveries.size();
|
||||
qint64 latestTimestamp = liveries.latestTimestampMsecsSinceEpoch();
|
||||
if (n > 0 && latestTimestamp < 0)
|
||||
@@ -343,6 +344,7 @@ namespace BlackCore
|
||||
distributors = CDistributorList::fromDatabaseJson(res);
|
||||
}
|
||||
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
const int n = distributors.size();
|
||||
qint64 latestTimestamp = distributors.latestTimestampMsecsSinceEpoch();
|
||||
if (n > 0 && latestTimestamp < 0)
|
||||
@@ -386,6 +388,7 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
// synchronized update
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
const int n = models.size();
|
||||
qint64 latestTimestamp = models.latestTimestampMsecsSinceEpoch();
|
||||
if (n > 0 && latestTimestamp < 0)
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace BlackCore
|
||||
void CThreadedReader::doWork()
|
||||
{
|
||||
if (!doWorkCheck()) { return; }
|
||||
doWorkImpl();
|
||||
this->doWorkImpl();
|
||||
Q_ASSERT(m_periodicTime > 0);
|
||||
m_updateTimer.start(m_periodicTime); // restart
|
||||
}
|
||||
@@ -165,8 +165,8 @@ namespace BlackCore
|
||||
bool CThreadedReader::doWorkCheck() const
|
||||
{
|
||||
// sApp->hasWebDataServices() cannot be used, as some readers are already used during init phase
|
||||
if (!isEnabled()) { return false; }
|
||||
if (isAbandoned()) { return false; }
|
||||
if (!this->isEnabled()) { return false; }
|
||||
if (this->isAbandoned()) { return false; }
|
||||
if (!m_unitTest && (!sApp || sApp->isShuttingDown())) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user