MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / tryAsset

Method tryAsset

source/base/StarAssets.cpp:782–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780}
781
782shared_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
803shared_ptr<Assets::AssetData> Assets::getAsset(AssetId const& id) const {
804 MutexLocker assetsLocker(m_assetsMutex);

Callers

nothing calls this directly

Calls 4

formatFunction · 0.50
findMethod · 0.45
endMethod · 0.45
signalMethod · 0.45

Tested by

no test coverage detected