diff --git a/src/resource/ResourceManager.cpp b/src/resource/ResourceManager.cpp index b1f0b6f19..1a65fc839 100644 --- a/src/resource/ResourceManager.cpp +++ b/src/resource/ResourceManager.cpp @@ -342,24 +342,36 @@ void ResourceManager::DirtyResources(const ResourceFilter& filter) { }); } -void ResourceManager::UnloadResources(const ResourceFilter& filter) { - mThreadPool->submit_task([this, filter]() -> void { - auto list = GetArchiveManager()->ListFiles(filter.IncludeMasks, filter.ExcludeMasks); +void ResourceManager::DirtyResources(const std::string& searchMask) { + DirtyResources({ { searchMask }, {}, mDefaultCacheOwner, mDefaultCacheArchive }); +} - for (const auto& key : *list.get()) { - UnloadResource({ key, mDefaultCacheOwner, mDefaultCacheArchive }); - } - }); +void ResourceManager::UnloadResourcesAsync(const std::string& searchMask) { + UnloadResourcesAsync({ { searchMask }, {}, mDefaultCacheOwner, mDefaultCacheArchive }); } -void ResourceManager::DirtyResources(const std::string& searchMask) { - DirtyResources({ { searchMask }, {}, mDefaultCacheOwner, mDefaultCacheArchive }); +void ResourceManager::UnloadResourcesAsync(const ResourceFilter& filter) { + mThreadPool->submit_task([this, filter]() -> void { + UnloadResourcesProcess(filter); + }); } void ResourceManager::UnloadResources(const std::string& searchMask) { UnloadResources({ { searchMask }, {}, mDefaultCacheOwner, mDefaultCacheArchive }); } +void ResourceManager::UnloadResources(const ResourceFilter& filter) { + UnloadResourcesProcess(filter); +} + +void ResourceManager::UnloadResourcesProcess(const ResourceFilter& filter) { + auto list = GetArchiveManager()->ListFiles(filter.IncludeMasks, filter.ExcludeMasks); + + for (const auto& key : *list.get()) { + UnloadResource({ key, mDefaultCacheOwner, mDefaultCacheArchive }); + } +} + std::shared_ptr ResourceManager::GetArchiveManager() { return mArchiveManager; } diff --git a/src/resource/ResourceManager.h b/src/resource/ResourceManager.h index e3a2e0cce..2994e4ebb 100644 --- a/src/resource/ResourceManager.h +++ b/src/resource/ResourceManager.h @@ -95,6 +95,8 @@ class ResourceManager { void DirtyResources(const ResourceFilter& filter); void UnloadResources(const std::string& searchMask); void UnloadResources(const ResourceFilter& filter); + void UnloadResourcesAsync(const std::string& searchMask); + void UnloadResourcesAsync(const ResourceFilter& filter); bool OtrSignatureCheck(const char* fileName); bool IsAltAssetsEnabled(); @@ -102,6 +104,7 @@ class ResourceManager { protected: std::shared_ptr>> LoadResourcesProcess(const ResourceFilter& filter); + void UnloadResourcesProcess(const ResourceFilter& filter); std::variant> CheckCache(const ResourceIdentifier& identifier, bool loadExact = false); std::shared_ptr LoadFileProcess(const ResourceIdentifier& identifier,