mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T292, Ref T285 avoid unnecessary calls of cache synchronize in DB readers
Rational: Normally calling synchronize multiple times does not matter. However, it can time out if the cache is in use (e.g. saving) and create an exception. This exception is just unwanted "noise".
This commit is contained in:
@@ -152,7 +152,7 @@ namespace BlackCore
|
||||
|
||||
void CAirportDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
||||
{
|
||||
if (entities.testFlag(CEntityFlags::AirportEntity)) { m_airportCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::AirportEntity)) { if (m_syncedAirportCache) { return; } m_syncedAirportCache = true; m_airportCache.synchronize(); }
|
||||
}
|
||||
|
||||
void CAirportDataReader::admitCaches(CEntityFlags::Entity entities)
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
#include "blackcore/db/databasereader.h"
|
||||
#include "blackmisc/aviation/airportlist.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <atomic>
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
@@ -73,7 +75,8 @@ namespace BlackCore
|
||||
BlackMisc::Db::CDbFlags::DataRetrievalModeFlag mode = BlackMisc::Db::CDbFlags::DbReading, const QDateTime &newerThan = QDateTime());
|
||||
|
||||
private:
|
||||
BlackMisc::CData<BlackCore::Data::TDbAirportCache> m_airportCache {this, &CAirportDataReader::airportCacheChanged};
|
||||
BlackMisc::CData<BlackCore::Data::TDbAirportCache> m_airportCache {this, &CAirportDataReader::airportCacheChanged}; //!< cache file
|
||||
std::atomic_bool m_syncedAirportCache { false }; //!< already synchronized?
|
||||
|
||||
//! Reader URL (we read from where?) used to detect changes of location
|
||||
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache {this, &CAirportDataReader::baseUrlCacheChanged };
|
||||
|
||||
@@ -576,9 +576,9 @@ namespace BlackCore
|
||||
|
||||
void CIcaoDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
||||
{
|
||||
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { m_aircraftIcaoCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) { m_airlineIcaoCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::CountryEntity)) { m_countryCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::AircraftIcaoEntity)) { if (m_syncedAircraftIcaoCache) { return; } m_syncedAircraftIcaoCache = true; m_aircraftIcaoCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::AirlineIcaoEntity)) { if (m_syncedAirlineIcaoCache) { return; } m_syncedAirlineIcaoCache = true; m_airlineIcaoCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::CountryEntity)) { if (m_syncedCountryCache) { return; } m_syncedCountryCache = true; m_countryCache.synchronize(); }
|
||||
}
|
||||
|
||||
void CIcaoDataReader::admitCaches(CEntityFlags::Entity entities)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QObject>
|
||||
#include <QReadWriteLock>
|
||||
#include <QString>
|
||||
#include <atomic>
|
||||
|
||||
class QDateTime;
|
||||
class QNetworkReply;
|
||||
@@ -162,6 +163,9 @@ namespace BlackCore
|
||||
BlackMisc::CData<BlackCore::Data::TDbAircraftIcaoCache> m_aircraftIcaoCache {this, &CIcaoDataReader::aircraftIcaoCacheChanged };
|
||||
BlackMisc::CData<BlackCore::Data::TDbAirlineIcaoCache> m_airlineIcaoCache {this, &CIcaoDataReader::airlineIcaoCacheChanged };
|
||||
BlackMisc::CData<BlackCore::Data::TDbCountryCache> m_countryCache {this, &CIcaoDataReader::countryCacheChanged };
|
||||
std::atomic_bool m_syncedAircraftIcaoCache { false }; //!< already synchronized?
|
||||
std::atomic_bool m_syncedAirlineIcaoCache { false }; //!< already synchronized?
|
||||
std::atomic_bool m_syncedCountryCache { false }; //!< already synchronized?
|
||||
|
||||
//! Reader URL (we read from where?) used to detect changes of location
|
||||
BlackMisc::CData<BlackCore::Data::TDbIcaoReaderBaseUrl> m_readerUrlCache {this, &CIcaoDataReader::baseUrlCacheChanged };
|
||||
|
||||
@@ -579,9 +579,9 @@ namespace BlackCore
|
||||
|
||||
void CModelDataReader::synchronizeCaches(CEntityFlags::Entity entities)
|
||||
{
|
||||
if (entities.testFlag(CEntityFlags::LiveryEntity)) { m_liveryCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::ModelEntity)) { m_modelCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::DistributorEntity)) { m_distributorCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::LiveryEntity)) { if (m_syncedLiveryCache) { return; } m_syncedLiveryCache = true; m_liveryCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::ModelEntity)) { if (m_syncedModelCache) { return; } m_syncedModelCache = true; m_modelCache.synchronize(); }
|
||||
if (entities.testFlag(CEntityFlags::DistributorEntity)) { if (m_syncedDistributorCache) { return; } m_syncedDistributorCache = true; m_distributorCache.synchronize(); }
|
||||
}
|
||||
|
||||
void CModelDataReader::admitCaches(CEntityFlags::Entity entities)
|
||||
|
||||
@@ -165,6 +165,9 @@ namespace BlackCore
|
||||
BlackMisc::CData<BlackCore::Data::TDbLiveryCache> m_liveryCache { this, &CModelDataReader::liveryCacheChanged };
|
||||
BlackMisc::CData<BlackCore::Data::TDbModelCache> m_modelCache { this, &CModelDataReader::modelCacheChanged };
|
||||
BlackMisc::CData<BlackCore::Data::TDbDistributorCache> m_distributorCache { this, &CModelDataReader::distributorCacheChanged };
|
||||
std::atomic_bool m_syncedLiveryCache { false }; //!< already synchronized?
|
||||
std::atomic_bool m_syncedModelCache { false }; //!< already synchronized?
|
||||
std::atomic_bool m_syncedDistributorCache { false }; //!< already synchronized?
|
||||
|
||||
//! Reader URL (we read from where?) used to detect changes of location
|
||||
BlackMisc::CData<BlackCore::Data::TDbModelReaderBaseUrl> m_readerUrlCache { this, &CModelDataReader::baseUrlCacheChanged };
|
||||
|
||||
Reference in New Issue
Block a user