mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-29 12:45:40 +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);
|
Q_FUNC_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->doWorkCheck()) { return; }
|
||||||
const int size = airports.size();
|
const int size = airports.size();
|
||||||
qint64 latestTimestamp = airports.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = airports.latestTimestampMsecsSinceEpoch();
|
||||||
if (size > 0 && latestTimestamp < 0)
|
if (size > 0 && latestTimestamp < 0)
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ namespace BlackCore
|
|||||||
Q_FUNC_INFO);
|
Q_FUNC_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->doWorkCheck()) { return; }
|
||||||
const int n = codes.size();
|
const int n = codes.size();
|
||||||
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch(); // ignores duplicates
|
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch(); // ignores duplicates
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
@@ -342,6 +343,7 @@ namespace BlackCore
|
|||||||
Q_FUNC_INFO);
|
Q_FUNC_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->doWorkCheck()) { return; }
|
||||||
const int n = codes.size();
|
const int n = codes.size();
|
||||||
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = codes.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
@@ -382,6 +384,7 @@ namespace BlackCore
|
|||||||
countries = CCountryList::fromDatabaseJson(res);
|
countries = CCountryList::fromDatabaseJson(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->doWorkCheck()) { return; }
|
||||||
const int n = countries.size();
|
const int n = countries.size();
|
||||||
qint64 latestTimestamp = countries.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = countries.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
|
|||||||
@@ -301,6 +301,7 @@ namespace BlackCore
|
|||||||
liveries = CLiveryList::fromDatabaseJson(res);
|
liveries = CLiveryList::fromDatabaseJson(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->doWorkCheck()) { return; }
|
||||||
const int n = liveries.size();
|
const int n = liveries.size();
|
||||||
qint64 latestTimestamp = liveries.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = liveries.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
@@ -343,6 +344,7 @@ namespace BlackCore
|
|||||||
distributors = CDistributorList::fromDatabaseJson(res);
|
distributors = CDistributorList::fromDatabaseJson(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this->doWorkCheck()) { return; }
|
||||||
const int n = distributors.size();
|
const int n = distributors.size();
|
||||||
qint64 latestTimestamp = distributors.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = distributors.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
@@ -386,6 +388,7 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
// synchronized update
|
// synchronized update
|
||||||
|
if (!this->doWorkCheck()) { return; }
|
||||||
const int n = models.size();
|
const int n = models.size();
|
||||||
qint64 latestTimestamp = models.latestTimestampMsecsSinceEpoch();
|
qint64 latestTimestamp = models.latestTimestampMsecsSinceEpoch();
|
||||||
if (n > 0 && latestTimestamp < 0)
|
if (n > 0 && latestTimestamp < 0)
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ namespace BlackCore
|
|||||||
void CThreadedReader::doWork()
|
void CThreadedReader::doWork()
|
||||||
{
|
{
|
||||||
if (!doWorkCheck()) { return; }
|
if (!doWorkCheck()) { return; }
|
||||||
doWorkImpl();
|
this->doWorkImpl();
|
||||||
Q_ASSERT(m_periodicTime > 0);
|
Q_ASSERT(m_periodicTime > 0);
|
||||||
m_updateTimer.start(m_periodicTime); // restart
|
m_updateTimer.start(m_periodicTime); // restart
|
||||||
}
|
}
|
||||||
@@ -165,8 +165,8 @@ namespace BlackCore
|
|||||||
bool CThreadedReader::doWorkCheck() const
|
bool CThreadedReader::doWorkCheck() const
|
||||||
{
|
{
|
||||||
// sApp->hasWebDataServices() cannot be used, as some readers are already used during init phase
|
// sApp->hasWebDataServices() cannot be used, as some readers are already used during init phase
|
||||||
if (!isEnabled()) { return false; }
|
if (!this->isEnabled()) { return false; }
|
||||||
if (isAbandoned()) { return false; }
|
if (this->isAbandoned()) { return false; }
|
||||||
if (!m_unitTest && (!sApp || sApp->isShuttingDown())) { return false; }
|
if (!m_unitTest && (!sApp || sApp->isShuttingDown())) { return false; }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user