mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-04 03:46:42 +01:00
Merge pull request #6284 from JosJuice/qt-gamefilecache-mutex
DolphinQt2: Don't use a mutex in GameFileCache
This commit is contained in:
commit
e31f8f8ecb
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
@ -20,24 +21,18 @@ GameFileCache::GameFileCache()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameFileCache::IsCached(const QString& path)
|
bool GameFileCache::IsCached(const QString& path) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
|
||||||
|
|
||||||
return m_gamefiles.contains(path);
|
return m_gamefiles.contains(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameFile GameFileCache::GetFile(const QString& path)
|
GameFile GameFileCache::GetFile(const QString& path) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
|
||||||
|
|
||||||
return m_gamefiles[path];
|
return m_gamefiles[path];
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameFileCache::Load()
|
void GameFileCache::Load()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
|
||||||
|
|
||||||
QFile file(m_path);
|
QFile file(m_path);
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly))
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
@ -56,10 +51,8 @@ void GameFileCache::Load()
|
|||||||
stream >> m_gamefiles;
|
stream >> m_gamefiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameFileCache::Save()
|
void GameFileCache::Save() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
|
||||||
|
|
||||||
QFile file(m_path);
|
QFile file(m_path);
|
||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly))
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
@ -74,14 +67,10 @@ void GameFileCache::Save()
|
|||||||
|
|
||||||
void GameFileCache::Update(const GameFile& gamefile)
|
void GameFileCache::Update(const GameFile& gamefile)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
|
||||||
|
|
||||||
m_gamefiles[gamefile.GetFilePath()] = gamefile;
|
m_gamefiles[gamefile.GetFilePath()] = gamefile;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> GameFileCache::GetCached()
|
QList<QString> GameFileCache::GetCached() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(m_mutex);
|
|
||||||
|
|
||||||
return m_gamefiles.keys();
|
return m_gamefiles.keys();
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QFile>
|
#include <QList>
|
||||||
|
#include <QMap>
|
||||||
#include <mutex>
|
#include <QString>
|
||||||
|
|
||||||
#include "DolphinQt2/GameList/GameFile.h"
|
#include "DolphinQt2/GameList/GameFile.h"
|
||||||
|
|
||||||
@ -16,15 +16,14 @@ public:
|
|||||||
explicit GameFileCache();
|
explicit GameFileCache();
|
||||||
|
|
||||||
void Update(const GameFile& gamefile);
|
void Update(const GameFile& gamefile);
|
||||||
void Save();
|
void Save() const;
|
||||||
void Load();
|
void Load();
|
||||||
bool IsCached(const QString& path);
|
bool IsCached(const QString& path) const;
|
||||||
GameFile GetFile(const QString& path);
|
GameFile GetFile(const QString& path) const;
|
||||||
QList<QString> GetCached();
|
QList<QString> GetCached() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_path;
|
QString m_path;
|
||||||
|
|
||||||
QMap<QString, GameFile> m_gamefiles;
|
QMap<QString, GameFile> m_gamefiles;
|
||||||
std::mutex m_mutex;
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user