Async load works, using exceptions for special resources.

This commit is contained in:
William Moberg
2016-01-14 16:27:45 +01:00
parent 9f185a1e35
commit 71047b08ec
13 changed files with 160 additions and 181 deletions
+3
View File
@@ -14,6 +14,7 @@ std::unordered_map<unsigned int, unsigned int> ResourceManager::m_ResourceCount;
FileWatcher ResourceManager::m_FileWatcher;
std::unordered_map<std::pair<std::string, std::string>, boost::thread> ResourceManager::m_LoadingThreads;
boost::recursive_mutex ResourceManager::m_Mutex;
const ResourceManager::SpecialResourcePointer ResourceManager::m_StillLoading;
unsigned int ResourceManager::GetTypeID(std::string resourceType)
{
@@ -92,6 +93,8 @@ Resource* ResourceManager::createResource(std::string resourceType, std::string
Resource* resource = nullptr;
try {
resource = facIt->second(resourceName);
} catch (const ThreadUnsafeResource::StillLoadingException&) {
resource = m_StillLoading;
} catch (const std::exception& e) {
LOG_ERROR("Failed to load resource \"%s\" of type \"%s\": %s", resourceName.c_str(), resourceType.c_str(), e.what());
}