refs #687, further performance improvements

* avoid redundant reads by excluding entities which will be periodically updated
* restart timers when data are received, avoid overlapping requests
This commit is contained in:
Klaus Basan
2016-06-26 00:13:02 +02:00
parent fcba4f2e75
commit 0939b1f08f
7 changed files with 45 additions and 13 deletions

View File

@@ -68,10 +68,11 @@ namespace BlackCore
void CVatsimBookingReader::ps_read()
{
this->threadAssertCheck();
this->restartTimer(true); // when timer active, restart so we cause no undesired reads
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application");
const QUrl url(sApp->getGlobalSetup().getVatsimBookingsUrl());
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimBookingReader::ps_parseBookings});
}
@@ -114,10 +115,11 @@ namespace BlackCore
if (this->getUpdateTimestamp() == updateTimestamp) return; // nothing to do
// save parsing and all follow up actions if nothing changed
this->restartTimer(); // do not consider time for reading
bool changed = this->didContentChange(xmlData, xmlData.indexOf("</timestamp>"));
if (!changed)
{
CLogMessage(this).info("Bookings unchanged, skipped");
CLogMessage(this).info("Read bookings unchanged, skipped");
return; // stop, terminate straight away, ending thread
}
}

View File

@@ -187,6 +187,7 @@ namespace BlackCore
void CVatsimDataFileReader::ps_read()
{
this->threadAssertCheck();
this->restartTimer(true); // when timer active, restart so we cause no undesired reads
// round robin for load balancing
// remark: Don't use QThread to run network operations in the background
@@ -196,7 +197,6 @@ namespace BlackCore
const QUrl url(urls.obtainNextWorkingUrl(true));
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimDataFileReader::ps_parseVatsimFile});
}
void CVatsimDataFileReader::ps_parseVatsimFile(QNetworkReply *nwReplyPtr)
@@ -222,8 +222,8 @@ namespace BlackCore
nwReply->close(); // close asap
if (dataFileData.isEmpty()) { return; }
// Quick check by hash
if (!this->didContentChange(dataFileData))
this->restartTimer(); // do not consider time for reading
if (!this->didContentChange(dataFileData)) // Quick check by hash
{
CLogMessage(this).info("VATSIM file has same content, skipped");
return;

View File

@@ -82,6 +82,8 @@ namespace BlackCore
void CVatsimMetarReader::ps_readMetars()
{
this->threadAssertCheck();
this->restartTimer(true); // when timer active, restart so we cause no undesired reads
CFailoverUrlList urls(sApp->getVatsimMetarUrls());
const CUrl url(urls.obtainNextWorkingUrl(true));
if (url.isEmpty()) { return; }
@@ -110,8 +112,8 @@ namespace BlackCore
QString metarData = nwReply->readAll();
nwReply->close(); // close asap
// Quick check by hash
if (!this->didContentChange(metarData))
this->restartTimer(); // do not consider time for reading
if (!this->didContentChange(metarData)) // Quick check by hash
{
CLogMessage(this).info("METAR file has same content, skipped");
return;