VideoCommon: add additional locks around asset access and usage to ensure thread safety

This commit is contained in:
iwubcode
2023-06-04 23:01:29 -05:00
parent ce2b63dcc0
commit 9d7ab47738
7 changed files with 92 additions and 56 deletions

View File

@ -16,6 +16,7 @@ bool CustomAsset::Load()
const auto load_information = LoadImpl(m_asset_id);
if (load_information.m_bytes_loaded > 0)
{
std::lock_guard lk(m_info_lock);
m_bytes_loaded = load_information.m_bytes_loaded;
m_last_loaded_time = load_information.m_load_time;
}
@ -29,6 +30,7 @@ CustomAssetLibrary::TimeType CustomAsset::GetLastWriteTime() const
const CustomAssetLibrary::TimeType& CustomAsset::GetLastLoadedTime() const
{
std::lock_guard lk(m_info_lock);
return m_last_loaded_time;
}
@ -39,6 +41,7 @@ const CustomAssetLibrary::AssetID& CustomAsset::GetAssetId() const
std::size_t CustomAsset::GetByteSizeInMemory() const
{
std::lock_guard lk(m_info_lock);
return m_bytes_loaded;
}