From e44b64b82c240342e72b6c8e425b03d97554008d Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 4 Jan 2018 14:07:01 +0100 Subject: 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. --- Source/Core/DolphinQt2/GameList/GameFileCache.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'Source/Core/DolphinQt2/GameList/GameFileCache.cpp') 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 #include +#include #include #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 guard(m_mutex); - return m_gamefiles.contains(path); } -GameFile GameFileCache::GetFile(const QString& path) +GameFile GameFileCache::GetFile(const QString& path) const { - std::lock_guard guard(m_mutex); - return m_gamefiles[path]; } void GameFileCache::Load() { - std::lock_guard 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 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 guard(m_mutex); - m_gamefiles[gamefile.GetFilePath()] = gamefile; } -QList GameFileCache::GetCached() +QList GameFileCache::GetCached() const { - std::lock_guard guard(m_mutex); - return m_gamefiles.keys(); } -- cgit v1.2.3