From 00c8543306aad755901db40133c33fab4fc7b037 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Fri, 17 Mar 2023 16:07:17 -0600 Subject: [PATCH] Switch to std::list for adding & removing assets in deterministic order (#2543) --- include/openspace/scene/assetmanager.h | 6 +++--- src/scene/assetmanager.cpp | 17 ++++------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/include/openspace/scene/assetmanager.h b/include/openspace/scene/assetmanager.h index 14161ae61b..7c4a4d42d4 100644 --- a/include/openspace/scene/assetmanager.h +++ b/include/openspace/scene/assetmanager.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace openspace { @@ -164,10 +164,10 @@ private: /// This list contains all of the assets that are queued to be loading in the next /// update call - std::unordered_set _assetAddQueue; + std::list _assetAddQueue; /// The list contains all of the assets that should be removed in the next update call - std::unordered_set _assetRemoveQueue; + std::list _assetRemoveQueue; /// This list contains all assets that need to be initialized in the next update call std::vector _toBeInitialized; diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index 79006813d5..86636a0dc1 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -300,24 +300,15 @@ void AssetManager::update() { void AssetManager::add(const std::string& path) { ghoul_precondition(!path.empty(), "Path must not be empty"); // First check if the path is already in the remove queue. If so, remove it from there - const auto it = _assetRemoveQueue.find(path); - if (it != _assetRemoveQueue.end()) { - _assetRemoveQueue.erase(it); - } - - _assetAddQueue.insert(path); + _assetRemoveQueue.remove(path); + _assetAddQueue.push_back(path); } void AssetManager::remove(const std::string& path) { ghoul_precondition(!path.empty(), "Path must not be empty"); - // First check if the path is already in the add queue. If so, remove it from there - const auto it = _assetAddQueue.find(path); - if (it != _assetAddQueue.end()) { - _assetAddQueue.erase(it); - } - - _assetRemoveQueue.insert(path); + _assetAddQueue.remove(path); + _assetRemoveQueue.push_back(path); } std::vector AssetManager::allAssets() const {