mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
VideoCommon: avoid race conditions with asset load/unload by moving the lock to the entire function, favor atomics for the memory/time getters
This commit is contained in:
@ -6,9 +6,9 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoCommon/Assets/CustomAssetLibrary.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
namespace VideoCommon
|
||||
{
|
||||
@ -36,7 +36,7 @@ public:
|
||||
std::size_t Unload();
|
||||
|
||||
// Returns the time that the data was last loaded
|
||||
const TimeType& GetLastLoadedTime() const;
|
||||
TimeType GetLastLoadedTime() const;
|
||||
|
||||
// Returns an id that uniquely identifies this asset
|
||||
const CustomAssetLibrary::AssetID& GetAssetId() const;
|
||||
@ -60,8 +60,8 @@ private:
|
||||
std::size_t m_handle;
|
||||
|
||||
mutable std::mutex m_info_lock;
|
||||
std::size_t m_bytes_loaded = 0;
|
||||
TimeType m_last_loaded_time = {};
|
||||
std::atomic<std::size_t> m_bytes_loaded = 0;
|
||||
std::atomic<TimeType> m_last_loaded_time = {};
|
||||
};
|
||||
|
||||
// An abstract class that is expected to
|
||||
|
Reference in New Issue
Block a user