mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +08:00
refs #852 CAirspaceMonitor has no maximum number of parts per callsign,
but regularly prune the list based on timestamp age.
This commit is contained in:
@@ -1238,7 +1238,12 @@ namespace BlackCore
|
|||||||
// list sorted from new to old
|
// list sorted from new to old
|
||||||
QWriteLocker lock(&m_lockParts);
|
QWriteLocker lock(&m_lockParts);
|
||||||
CAircraftPartsList &partsList = this->m_partsByCallsign[callsign];
|
CAircraftPartsList &partsList = this->m_partsByCallsign[callsign];
|
||||||
partsList.push_frontMaxElements(parts, MaxPartsPerCallsign);
|
partsList.push_front(parts);
|
||||||
|
|
||||||
|
// remove outdated parts (but never remove the most recent one)
|
||||||
|
const auto predicate = [now = parts.getMSecsSinceEpoch()](const auto & p) { return p.getMSecsSinceEpoch() >= now - PartsPerCallsignMaxAgeInSeconds * 1000; };
|
||||||
|
const auto newEnd = std::find_if(partsList.rbegin(), partsList.rend(), predicate).base();
|
||||||
|
partsList.erase(newEnd, partsList.end());
|
||||||
|
|
||||||
partsList.front().setTimeOffsetMs(timeOffsetMs);
|
partsList.front().setTimeOffsetMs(timeOffsetMs);
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static constexpr int MaxSituationsPerCallsign = 6; //!< How many situations per callsign
|
static constexpr int MaxSituationsPerCallsign = 6; //!< How many situations per callsign
|
||||||
static constexpr int MaxPartsPerCallsign = 3; //!< How many parts per callsign
|
static constexpr int PartsPerCallsignMaxAgeInSeconds = 20; //!< How many seconds to keep parts for
|
||||||
|
|
||||||
//! Situations per callsign
|
//! Situations per callsign
|
||||||
using CSituationsPerCallsign = QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CAircraftSituationList>;
|
using CSituationsPerCallsign = QHash<BlackMisc::Aviation::CCallsign, BlackMisc::Aviation::CAircraftSituationList>;
|
||||||
|
|||||||
Reference in New Issue
Block a user