Ref T270, performance improvement by keeping less elevations cached

Rational: the idea was to keep track of ground elevations of all aircraft and hence using them for other aircraft on ground. But the "hit" ratio is bad, so we only keep a small number of elevations ("the last ones") and use those. The size of the cache is dynamically adjusted. Not moving aircraft are still found in that much smaller list.
This commit is contained in:
Klaus Basan
2018-06-01 01:26:28 +02:00
parent 87b96f8910
commit 2b9d9027a0
3 changed files with 48 additions and 8 deletions

View File

@@ -109,7 +109,12 @@ namespace BlackCore
void ISimulator::rememberElevationAndCG(const CCallsign &callsign, const Geo::CElevationPlane &elevation, const CLength &cg)
{
if (callsign.isEmpty()) { return; }
if (!elevation.isNull()) { this->rememberGroundElevation(elevation); }
if (!elevation.isNull())
{
const int aircraftCount = this->getAircraftInRangeCount();
this->setRememberMaxElevations(aircraftCount * 3); // at least 3 elevations per aircraft, even better as not all are requesting elevations
this->rememberGroundElevation(elevation);
}
if (!cg.isNull() && !this->hasSameCG(cg, callsign)) { this->insertCG(cg, callsign); }
}
@@ -120,9 +125,11 @@ namespace BlackCore
{
// decouple, follow up of signal can include unloading
// simulator so this should happen strictly asyncronously (which is like forcing Qt::QueuedConnection)
QPointer<ISimulator> myself(this);
QTimer::singleShot(0, this, [ = ]
{
emit this->simulatorStatusChanged(newStatus);
if (!myself) { return; }
emit myself->simulatorStatusChanged(newStatus);
});
}
}