Revert "Android: Don't hold gameFileCache lock during updateAdditionalMetadata"
This reverts commitfb265b610d
. The optimization in that commit is safe when the executor thread is writing and the GUI thread is reading, but I had failed to take into account that it's unsafe when the GUI thread is writing and the executor thread is reading. (The native UpdateAdditionalMetadata function loops through m_cached_files, which is unsafe if another thread is adding elements to m_cached_files simultaneously.) Losing out on this optimization isn't too bad, because719930bb39
makes it very unlikely that both threads will want the lock at the same time.
This commit is contained in:
parent
481df6b660
commit
51debaeb47
|
@ -227,11 +227,9 @@ public final class GameFileCacheManager
|
|||
{
|
||||
String[] gamePaths = GameFileCache.getAllGamePaths();
|
||||
|
||||
boolean changed;
|
||||
synchronized (sGameFileCache)
|
||||
{
|
||||
changed = sGameFileCache.update(gamePaths);
|
||||
}
|
||||
boolean changed = sGameFileCache.update(gamePaths);
|
||||
if (changed)
|
||||
{
|
||||
updateGameFileArray();
|
||||
|
@ -248,6 +246,7 @@ public final class GameFileCacheManager
|
|||
sGameFileCache.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sRescanInProgress.postValue(false);
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
|
||||
add_definitions(-D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
|
||||
# The replacement for the old atomic shared_ptr functions was added in C++20, so we can't use it yet
|
||||
add_definitions(-D_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING)
|
||||
endif()
|
||||
|
||||
if (NOT MSVC)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "UICommon/GameFileCache.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
@ -204,7 +203,7 @@ bool GameFileCache::UpdateAdditionalMetadata(std::shared_ptr<GameFile>* game_fil
|
|||
if (custom_cover_changed)
|
||||
copy->CustomCoverCommit();
|
||||
|
||||
std::atomic_store(game_file, std::move(copy));
|
||||
*game_file = std::move(copy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
<PreprocessorDefinitions>_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<!--Currently needed for some code in StringUtil used only on Android-->
|
||||
<PreprocessorDefinitions>_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<!--The replacement for the old atomic shared_ptr functions was added in C++20, so we can't use it yet-->
|
||||
<PreprocessorDefinitions>_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
||||
<!--Dolphin-specific definitions-->
|
||||
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">_ARCH_64=1;_M_X86=1;_M_X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
Loading…
Reference in New Issue