1
0
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:
Casey Link 2012-04-12 17:02:11 -05:00
parent 67d943bce3
commit c6beda5a7b
2 changed files with 7 additions and 0 deletions

View File

@ -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 );

View File

@ -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;
};
}