ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ckbsettingswriter.cpp
Go to the documentation of this file.
1 #include "ckbsettingswriter.h"
2 #include <QMutex>
3 
4 // Mirror ckbsettings.cpp
5 extern QAtomicInt cacheWritesInProgress;
6 extern QMutex settingsMutex, settingsCacheMutex;
7 #define lockMutex QMutexLocker locker(backing == _globalSettings ? &mutex : 0)
8 #define lockMutexStatic QMutexLocker locker(&settingsMutex)
9 #define lockMutexStatic2 QMutexLocker locker2(&settingsMutex)
10 #define lockMutexCache QMutexLocker locker(&settingsCacheMutex)
11 
12 CkbSettingsWriter::CkbSettingsWriter(QSettings* backing, const QStringList& removals, const QMap<QString, QVariant>& updates) :
13  _backing(backing), _removals(removals), _updates(updates) {
15 }
16 
18  cacheWritesInProgress.deref();
19 }
20 
23  // Process key removals
24  foreach(const QString& rm, _removals){
25  _backing->remove(rm);
26  }
27  // Process writes
28  QMapIterator<QString, QVariant> i(_updates);
29  while(i.hasNext()){
30  i.next();
31  _backing->setValue(i.key(), i.value());
32  // Updating the global cache was done above
33  }
34  _backing->sync();
35  deleteLater();
36 }
QMutex settingsCacheMutex
#define lockMutexStatic
QMutex settingsMutex
CkbSettingsWriter(QSettings *backing, const QStringList &removals, const QMap< QString, QVariant > &updates)
QMap< QString, QVariant > _updates
QAtomicInt cacheWritesInProgress