-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added background save for config (to work better on ZFS)
- Loading branch information
Showing
3 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* Josip Medved <[email protected]> * www.medo64.com * MIT License */ | ||
|
||
// 2021-12-10: Added background save | ||
// 2020-05-25: Using strongly typed enums | ||
// 2020-05-05: Added stateRead/stateWrite for integers, longs, and doubles | ||
// Allowing : and = in key name | ||
|
@@ -9,14 +10,15 @@ | |
// 2019-11-01: Fixed readMany implementation | ||
// 2019-11-17: Added stateReadMany and stateWriteMany | ||
// Added option to set paths manually | ||
// 2020-03-15: If QApplication hasn't bee initializesd, assume installed on Linux | ||
// 2020-03-15: If QApplication hasn't been initialized, assume installed on Linux | ||
|
||
#pragma once | ||
|
||
#include <QHash> | ||
#include <QMutex> | ||
#include <QString> | ||
#include <QStringList> | ||
#include <QThread> | ||
#include <QVariant> | ||
#include <QVector> | ||
|
||
|
@@ -291,6 +293,25 @@ class Config { | |
static QString dataDirectoryPathWhenPortable(); | ||
static QString dataDirectoryPathWhenInstalled(); | ||
|
||
private: | ||
class ConfigSaveThread : private QThread { | ||
public: | ||
explicit ConfigSaveThread(void); | ||
~ConfigSaveThread(); | ||
|
||
public: | ||
void requestSave(); | ||
|
||
public: | ||
ConfigSaveThread(const ConfigSaveThread&) = delete; | ||
void operator=(const ConfigSaveThread&) = delete; | ||
|
||
private: | ||
QMutex _syncRoot; | ||
bool _saveRequested = false; | ||
void run(); | ||
}; | ||
|
||
private: | ||
class ConfigFile { | ||
public: | ||
|
@@ -364,5 +385,6 @@ class Config { | |
static ConfigFile* getStateFile(); | ||
static void resetStateFile(); | ||
static ConfigFile* _stateFile; | ||
static Config::ConfigSaveThread _configSaveThread; | ||
|
||
}; |