mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 09:19:41 +01:00
Add a Cache mutex to protect shared data
This commit is contained in:
parent
67d943bce3
commit
c6beda5a7b
@ -22,6 +22,7 @@
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
#include <QMutexLocker>
|
||||
|
||||
using namespace TomahawkUtils;
|
||||
|
||||
@ -53,6 +54,8 @@ Cache::~Cache()
|
||||
|
||||
void Cache::pruneTimerFired()
|
||||
{
|
||||
QMutexLocker mutex_locker( &m_mutex );
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "Pruning tomahawkcache";
|
||||
qlonglong currentMSecsSinceEpoch = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
@ -79,6 +82,8 @@ void Cache::pruneTimerFired()
|
||||
|
||||
QVariant Cache::getData ( const QString& identifier, const QString& key )
|
||||
{
|
||||
QMutexLocker mutex_locker( &m_mutex );
|
||||
|
||||
const QString cacheDir = m_cacheBaseDir + identifier;
|
||||
QSettings cached_settings ( cacheDir, QSettings::IniFormat );
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "dllmacro.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <QSettings>
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
@ -63,6 +64,7 @@ private:
|
||||
QString m_cacheBaseDir;
|
||||
QSettings m_cacheManifest;
|
||||
QTimer m_pruneTimer;
|
||||
QMutex m_mutex;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user