MCPcopy Create free account
hub / github.com/defold/defold / DoPreloaderUpdateOneReq

Function DoPreloaderUpdateOneReq

engine/resource/src/resource_preloader.cpp:792–887  ·  view source on GitHub ↗

Returns true if the item or any of its children is found that has completed its loading from the load queue

Source from the content-addressed store, hash-verified

790
791 // Returns true if the item or any of its children is found that has completed its loading from the load queue
792 static bool DoPreloaderUpdateOneReq(HPreloader preloader, TRequestIndex index, PreloadRequest* req)
793 {
794 DM_PROFILE("DoPreloaderUpdateOneReq");
795
796 assert(!req->m_Resource);
797
798 if (req->m_PathDescriptor.m_ResourceType == 0)
799 {
800 req->m_LoadResult = RESULT_UNKNOWN_RESOURCE_TYPE;
801 RemoveFromParentPendingCount(preloader, req);
802 if (PreloaderTryPruneParent(preloader, req))
803 {
804 return true;
805 }
806 return false;
807 }
808
809 // If loading it must finish first before trying to go down to children
810 if (req->m_LoadRequest)
811 {
812 void* buffer;
813 uint32_t buffer_size;
814 uint32_t resource_size;
815
816 // Can hold the buffer till we FreeLoad it
817 dmLoadQueue::LoadResult res;
818 dmLoadQueue::Result e = dmLoadQueue::EndLoad(preloader->m_LoadQueue, req->m_LoadRequest, &buffer, &buffer_size, &resource_size, &res);
819 if (e == dmLoadQueue::RESULT_PENDING)
820 {
821 return false;
822 }
823 preloader->m_LoadQueueFull = false;
824
825 if (FinishLoad(preloader, req, res, buffer, buffer_size, resource_size))
826 {
827 return true;
828 }
829 return false;
830 }
831
832 // It has a buffer if is waiting for children to complete first
833 if (req->m_Buffer)
834 {
835 // traverse depth first
836 if (PreloaderUpdateOneItem(preloader, req->m_FirstChild))
837 {
838 return true;
839 }
840 return false;
841 }
842
843 // It might have been loaded by unhinted resource Gets or loaded by a different preloader, just grab & bump refcount
844 ResourceDescriptor* rd = FindByHash(preloader->m_Factory, req->m_PathDescriptor.m_CanonicalPathHash);
845 if (rd)
846 {
847 rd->m_ReferenceCount++;
848 req->m_Resource = rd->m_Resource;
849 req->m_LoadResult = RESULT_OK;

Callers 1

PreloaderUpdateOneItemFunction · 0.85

Calls 11

PreloaderTryPruneParentFunction · 0.85
FinishLoadFunction · 0.85
PreloaderUpdateOneItemFunction · 0.85
FindByHashFunction · 0.85
RemoveChildrenFunction · 0.85
IsPathInProgressFunction · 0.85
MarkPathInProgressFunction · 0.85
assertFunction · 0.50
EndLoadFunction · 0.50
BeginLoadFunction · 0.50

Tested by

no test coverage detected