mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T105, use new style with threaded readers
* use doWorkCheck * relaxed doWorkCheck in unit tests * removed isShuttingDown, gracefulShutdown * set timer object name (in case something is wrong, we might see the name in the log)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
2fbd2c6382
commit
b6b1b96ec4
@@ -149,7 +149,7 @@ namespace BlackCore
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReplyPtr);
|
||||
if (res.hasErrorMessage())
|
||||
@@ -196,7 +196,7 @@ namespace BlackCore
|
||||
void CAirportDataReader::ps_read(CEntityFlags::Entity entity, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
this->threadAssertCheck();
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
entity &= CEntityFlags::AirportEntity;
|
||||
if (!this->isNetworkAccessible())
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BlackCore
|
||||
|
||||
void CDatabaseReader::readInBackgroundThread(CEntityFlags::Entity entities, const QDateTime &newerThan)
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
// we accept cached data
|
||||
Q_ASSERT_X(!entities.testFlag(CEntityFlags::DbInfoObjectEntity), Q_FUNC_INFO, "Read info objects directly");
|
||||
@@ -226,7 +226,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_ASSERT_X(nwReply, Q_FUNC_INFO, "Missing reply");
|
||||
this->threadAssertCheck();
|
||||
if (this->isAbandoned())
|
||||
if (!this->doWorkCheck())
|
||||
{
|
||||
nwReply->abort();
|
||||
headerResponse.setMessage(CStatusMessage(this, CStatusMessage::SeverityError, "Terminated data parsing process"));
|
||||
@@ -469,7 +469,7 @@ namespace BlackCore
|
||||
|
||||
CUrl CDatabaseReader::getBaseUrl(CDbFlags::DataRetrievalModeFlag mode) const
|
||||
{
|
||||
if (this->isShuttingDown()) { return CUrl(); }
|
||||
if (!this->doWorkCheck()) { return CUrl(); }
|
||||
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing app object, URLs cannot be obtained");
|
||||
switch (mode)
|
||||
{
|
||||
@@ -500,7 +500,7 @@ namespace BlackCore
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
this->receivedSharedFileHeaderNonClosing(nwReplyPtr);
|
||||
nwReply->close();
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace BlackCore
|
||||
void CIcaoDataReader::ps_read(BlackMisc::Network::CEntityFlags::Entity entities, BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
this->threadAssertCheck(); // runs in background thread
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
entities &= CEntityFlags::AllIcaoAndCountries;
|
||||
if (!this->isNetworkAccessible())
|
||||
{
|
||||
@@ -229,7 +229,7 @@ namespace BlackCore
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
|
||||
if (res.hasErrorMessage())
|
||||
@@ -278,7 +278,7 @@ namespace BlackCore
|
||||
void CIcaoDataReader::ps_parseAirlineIcaoData(QNetworkReply *nwReplyPtr)
|
||||
{
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
|
||||
if (res.hasErrorMessage())
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace BlackCore
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
|
||||
const CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
|
||||
if (res.hasErrorMessage())
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace BlackCore
|
||||
void CModelDataReader::ps_read(CEntityFlags::Entity entities, CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan)
|
||||
{
|
||||
this->threadAssertCheck();
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
entities &= CEntityFlags::DistributorLiveryModel;
|
||||
if (!this->isNetworkAccessible())
|
||||
{
|
||||
@@ -248,7 +248,7 @@ namespace BlackCore
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
|
||||
if (res.hasErrorMessage())
|
||||
{
|
||||
@@ -290,7 +290,7 @@ namespace BlackCore
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
|
||||
if (res.hasErrorMessage())
|
||||
{
|
||||
@@ -332,7 +332,7 @@ namespace BlackCore
|
||||
// wrap pointer, make sure any exit cleans up reply
|
||||
// required to use delete later as object is created in a different thread
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
|
||||
if (this->isShuttingDown()) { return; }
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
CDatabaseReader::JsonDatastoreResponse res = this->setStatusAndTransformReplyIntoDatastoreResponse(nwReply.data());
|
||||
if (res.hasErrorMessage())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user