diff options
| author | JosJuice <josjuice@gmail.com> | 2018-01-04 14:07:01 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2018-01-04 16:33:15 +0100 |
| commit | e44b64b82c240342e72b6c8e425b03d97554008d (patch) | |
| tree | 1b2b861b297c930bd02b46257ac0cbd876503606 /Source/Core/DolphinQt2/GameList/GameFileCache.cpp | |
| parent | 637fbec35dc59ee4b2c6b8a0283d8af77670aac2 (diff) | |
DolphinQt2: Don't use a mutex in GameFileCache
GameTracker's usage of GameFileCache is thread-safe even without
using a mutex. All of its access to GameFileCache happens on the
thread m_load_thread, except for the call to GameFileCache::Load,
which finishes before m_load_thread starts executing.
Diffstat (limited to 'Source/Core/DolphinQt2/GameList/GameFileCache.cpp')
| -rw-r--r-- | Source/Core/DolphinQt2/GameList/GameFileCache.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/Source/Core/DolphinQt2/GameList/GameFileCache.cpp b/Source/Core/DolphinQt2/GameList/GameFileCache.cpp index a80194d4fc..167218c438 100644 --- a/Source/Core/DolphinQt2/GameList/GameFileCache.cpp +++ b/Source/Core/DolphinQt2/GameList/GameFileCache.cpp @@ -6,6 +6,7 @@ #include <QDataStream> #include <QDir> +#include <QFile> #include <QFileInfo> #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); } -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]; } void GameFileCache::Load() { - std::lock_guard<std::mutex> guard(m_mutex); - QFile file(m_path); if (!file.open(QIODevice::ReadOnly)) @@ -56,10 +51,8 @@ void GameFileCache::Load() stream >> m_gamefiles; } -void GameFileCache::Save() +void GameFileCache::Save() const { - std::lock_guard<std::mutex> guard(m_mutex); - QFile file(m_path); if (!file.open(QIODevice::WriteOnly)) @@ -74,14 +67,10 @@ void GameFileCache::Save() void GameFileCache::Update(const GameFile& gamefile) { - std::lock_guard<std::mutex> guard(m_mutex); - 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(); } |
