| 780 | } |
| 781 | |
| 782 | shared_ptr<Assets::AssetData> Assets::tryAsset(AssetId const& id) const { |
| 783 | MutexLocker assetsLocker(m_assetsMutex); |
| 784 | |
| 785 | auto i = m_assetsCache.find(id); |
| 786 | if (i != m_assetsCache.end()) { |
| 787 | if (i->second) { |
| 788 | freshen(i->second); |
| 789 | return i->second; |
| 790 | } else { |
| 791 | throw AssetException::format("Error loading asset {}", id.path); |
| 792 | } |
| 793 | } else { |
| 794 | auto j = m_queue.find(id); |
| 795 | if (j == m_queue.end()) { |
| 796 | m_queue[id] = QueuePriority::Load; |
| 797 | m_assetsQueued.signal(); |
| 798 | } |
| 799 | return {}; |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | shared_ptr<Assets::AssetData> Assets::getAsset(AssetId const& id) const { |
| 804 | MutexLocker assetsLocker(m_assetsMutex); |