mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user