summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-06-05 23:32:02 +0200
committerGitHub <noreply@github.com>2023-06-05 23:32:02 +0200
commit678db26f684edaac7c0ea699f2ac2b4771e31993 (patch)
treea766e794f51250d81d6d44e169eb716bd2579115 /Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp
parentce2b63dcc086f95c7278827a079f007faa7f34ad (diff)
parent9d7ab477387bb9afc00181dfa70e1e0d1a27b28b (diff)
Merge pull request #11891 from iwubcode/asset_thread_safety
VideoCommon: add additional locks around asset access / usage
Diffstat (limited to 'Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp')
-rw-r--r--Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp b/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp
index d2189e655b..bb404064d2 100644
--- a/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp
+++ b/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp
@@ -30,7 +30,7 @@ void CustomAssetLoader::Init()
std::this_thread::sleep_for(TIME_BETWEEN_ASSET_MONITOR_CHECKS);
- std::lock_guard lk(m_assets_lock);
+ std::lock_guard lk(m_asset_load_lock);
for (auto& [asset_id, asset_to_monitor] : m_assets_to_monitor)
{
if (auto ptr = asset_to_monitor.lock())
@@ -50,11 +50,11 @@ void CustomAssetLoader::Init()
{
if (ptr->Load())
{
- if (m_max_memory_available >= m_total_bytes_loaded + ptr->GetByteSizeInMemory())
+ std::lock_guard lk(m_asset_load_lock);
+ const std::size_t asset_memory_size = ptr->GetByteSizeInMemory();
+ if (m_max_memory_available >= m_total_bytes_loaded + asset_memory_size)
{
- m_total_bytes_loaded += ptr->GetByteSizeInMemory();
-
- std::lock_guard lk(m_assets_lock);
+ m_total_bytes_loaded += asset_memory_size;
m_assets_to_monitor.try_emplace(ptr->GetAssetId(), ptr);
}
else