aboutsummaryrefslogtreecommitdiff
path: root/launcher/RWStorage.h
diff options
context:
space:
mode:
authorAlexandru Ionut Tripon <alexandru.tripon97@gmail.com>2023-08-12 12:42:30 +0300
committerGitHub <noreply@github.com>2023-08-12 12:42:30 +0300
commitb3b2e9df35222209b4920202d86091eeeb87f03f (patch)
treece44c3877ee36c21279d142b2af1c393e7b87780 /launcher/RWStorage.h
parentca061080c13042642fb3bd49a29a863756f45866 (diff)
parent3aba7f8fec45c7c87be486d8f6b5c96f69facf93 (diff)
downloadPrismLauncher-b3b2e9df35222209b4920202d86091eeeb87f03f.tar.gz
PrismLauncher-b3b2e9df35222209b4920202d86091eeeb87f03f.tar.bz2
PrismLauncher-b3b2e9df35222209b4920202d86091eeeb87f03f.zip
Merge branch 'develop' into feat/acknowledge_release_type
Signed-off-by: Alexandru Ionut Tripon <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/RWStorage.h')
-rw-r--r--launcher/RWStorage.h31
1 files changed, 14 insertions, 17 deletions
diff --git a/launcher/RWStorage.h b/launcher/RWStorage.h
index 3028388e..5764d795 100644
--- a/launcher/RWStorage.h
+++ b/launcher/RWStorage.h
@@ -1,13 +1,12 @@
#pragma once
-#include <QWriteLocker>
-#include <QReadLocker>
#include <QMap>
+#include <QReadLocker>
#include <QSet>
+#include <QWriteLocker>
template <typename K, typename V>
-class RWStorage
-{
-public:
+class RWStorage {
+ public:
void add(K key, V value)
{
QWriteLocker l(&lock);
@@ -17,21 +16,19 @@ public:
V get(K key)
{
QReadLocker l(&lock);
- if(cache.contains(key))
- {
+ if (cache.contains(key)) {
return cache[key];
- }
- else return V();
+ } else
+ return V();
}
bool get(K key, V& value)
{
QReadLocker l(&lock);
- if(cache.contains(key))
- {
+ if (cache.contains(key)) {
value = cache[key];
return true;
- }
- else return false;
+ } else
+ return false;
}
bool has(K key)
{
@@ -41,15 +38,14 @@ public:
bool stale(K key)
{
QReadLocker l(&lock);
- if(!cache.contains(key))
+ if (!cache.contains(key))
return true;
return stale_entries.contains(key);
}
void setStale(K key)
{
QWriteLocker l(&lock);
- if(cache.contains(key))
- {
+ if (cache.contains(key)) {
stale_entries.insert(key);
}
}
@@ -59,7 +55,8 @@ public:
cache.clear();
stale_entries.clear();
}
-private:
+
+ private:
QReadWriteLock lock;
QMap<K, V> cache;
QSet<K> stale_entries;