mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
refs #536 Moved CDataCache serialization into a worker thread.
This commit is contained in:
@@ -249,19 +249,17 @@ namespace BlackMisc
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
CValueCachePacket values;
|
||||
auto status = loadFromFiles(dir, values);
|
||||
auto status = loadFromFiles(dir, getAllValues(), values);
|
||||
insertValues(values);
|
||||
return status;
|
||||
}
|
||||
|
||||
CStatusMessage CValueCache::loadFromFiles(const QString &dir, CValueCachePacket &o_values) const
|
||||
CStatusMessage CValueCache::loadFromFiles(const QString &dir, const CVariantMap ¤tValues, CValueCachePacket &o_values) const
|
||||
{
|
||||
QMutexLocker lock(&m_mutex);
|
||||
if (! QDir(dir).isReadable())
|
||||
{
|
||||
return CLogMessage(this).error("Failed to read directory %1") << dir;
|
||||
}
|
||||
auto currentValues = getAllValues();
|
||||
for (const auto &filename : QDir(dir).entryList({ "*.json" }, QDir::Files))
|
||||
{
|
||||
QFile file(dir + "/" + filename);
|
||||
|
||||
@@ -162,10 +162,12 @@ namespace BlackMisc
|
||||
|
||||
protected:
|
||||
//! Save specific values to Json files in a given directory.
|
||||
//! \threadsafe
|
||||
CStatusMessage saveToFiles(const QString &directory, const CVariantMap &values) const;
|
||||
|
||||
//! Load from Json files in a given directory any values which differ from the current ones, and insert them in o_values.
|
||||
CStatusMessage loadFromFiles(const QString &directory, CValueCachePacket &o_values) const;
|
||||
//! \threadsafe
|
||||
CStatusMessage loadFromFiles(const QString &directory, const CVariantMap ¤t, CValueCachePacket &o_values) const;
|
||||
|
||||
//! Mutex protecting operations which are critical on m_elements.
|
||||
mutable QMutex m_mutex { QMutex::Recursive };
|
||||
|
||||
Reference in New Issue
Block a user