diff options
| author | Christian Aguilera <cristian64@gmail.com> | 2020-09-27 04:01:54 +0200 |
|---|---|---|
| committer | Christian Aguilera <cristian64@gmail.com> | 2020-10-01 22:10:16 +0200 |
| commit | ee13e6ec80f4652274156867d8d44737f80f59ba (patch) | |
| tree | e85a5dc2948fbddf4493fffcc74364dcf27fa187 /Source/Core/UICommon/GameFileCache.cpp | |
| parent | 4ca92464c055e74580ebcdd39c4c7a9f5d239a95 (diff) | |
Improved responsiveness when refreshing game list.
Diffstat (limited to 'Source/Core/UICommon/GameFileCache.cpp')
| -rw-r--r-- | Source/Core/UICommon/GameFileCache.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp index c551016d7f..71c73a5f9f 100644 --- a/Source/Core/UICommon/GameFileCache.cpp +++ b/Source/Core/UICommon/GameFileCache.cpp @@ -90,7 +90,8 @@ std::shared_ptr<const GameFile> GameFileCache::AddOrGet(const std::string& path, bool GameFileCache::Update( const std::vector<std::string>& all_game_paths, std::function<void(const std::shared_ptr<const GameFile>&)> game_added_to_cache, - std::function<void(const std::string&)> game_removed_from_cache) + std::function<void(const std::string&)> game_removed_from_cache, + const std::atomic_bool& processing_halted) { // Copy game paths into a set, except ones that match DiscIO::ShouldHideFromGameList. // TODO: Prevent DoFileSearch from looking inside /files/ directories of DirectoryBlobs at all? @@ -113,6 +114,9 @@ bool GameFileCache::Update( auto end = m_cached_files.end(); while (it != end) { + if (processing_halted) + break; + if (game_paths.erase((*it)->GetFilePath())) { ++it; @@ -134,6 +138,9 @@ bool GameFileCache::Update( // aren't in m_cached_files, so we simply add all of them to m_cached_files. for (const std::string& path : game_paths) { + if (processing_halted) + break; + auto file = std::make_shared<GameFile>(path); if (file->IsValid()) { @@ -149,12 +156,16 @@ bool GameFileCache::Update( } bool GameFileCache::UpdateAdditionalMetadata( - std::function<void(const std::shared_ptr<const GameFile>&)> game_updated) + std::function<void(const std::shared_ptr<const GameFile>&)> game_updated, + const std::atomic_bool& processing_halted) { bool cache_changed = false; for (std::shared_ptr<GameFile>& file : m_cached_files) { + if (processing_halted) + break; + const bool updated = UpdateAdditionalMetadata(&file); cache_changed |= updated; if (game_updated && updated) |
